Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jyzb_platformV2
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
赵剑炜
jyzb_platformV2
Commits
c0b8da71
Commit
c0b8da71
authored
Nov 23, 2023
by
赵剑炜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
单警柜接口全部调整
parent
e67b6c45
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
238 行增加
和
81 行删除
+238
-81
CabinetBoxDto.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/CabinetBoxDto.java
+8
-1
CabinetDto.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/CabinetDto.java
+10
-1
CabinetReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/query/CabinetReq.java
+3
-2
UpdateCabinetBoxReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/UpdateCabinetBoxReq.java
+8
-6
UpdateCabinetReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/UpdateCabinetReq.java
+9
-8
CabinetBoxController.java
jyzb-biz/src/main/java/com/junmp/jyzb/controller/CabinetBoxController.java
+10
-2
CabinetController.java
jyzb-biz/src/main/java/com/junmp/jyzb/controller/CabinetController.java
+12
-4
Cabinet.java
jyzb-biz/src/main/java/com/junmp/jyzb/entity/Cabinet.java
+9
-11
CabinetBox.java
jyzb-biz/src/main/java/com/junmp/jyzb/entity/CabinetBox.java
+35
-5
CabinetBoxService.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/CabinetBoxService.java
+4
-2
CabinetService.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/CabinetService.java
+7
-1
CabinetBoxServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/CabinetBoxServiceImpl.java
+89
-20
CabinetServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/CabinetServiceImpl.java
+0
-0
OrderMainServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/OrderMainServiceImpl.java
+7
-18
RabbitMQSendMsg.java
jyzb-biz/src/main/java/com/junmp/jyzb/utils/RabbitMQSendMsg.java
+27
-0
没有找到文件。
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/CabinetBoxDto.java
View file @
c0b8da71
...
...
@@ -17,7 +17,7 @@ public class CabinetBoxDto implements Serializable {
* 箱号
*/
@ApiModelProperty
(
value
=
"箱门号"
)
private
Integer
BoxN
um
;
private
Integer
n
um
;
/**
* 异常状态:1正常/0异常
...
...
@@ -31,6 +31,7 @@ public class CabinetBoxDto implements Serializable {
@ApiModelProperty
(
value
=
"异常原因"
)
private
String
errorMsg
;
/**
* 箱门绑定警员id
*/
...
...
@@ -41,4 +42,10 @@ public class CabinetBoxDto implements Serializable {
*/
private
String
policeName
;
/**
* 箱门类型:1单警柜,2公共柜
*/
@ApiModelProperty
(
value
=
"箱门类型:1单警柜,2公共柜"
)
private
Integer
boxType
;
}
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/CabinetDto.java
View file @
c0b8da71
...
...
@@ -47,9 +47,18 @@ public class CabinetDto implements Serializable{
*/
@ApiModelProperty
(
value
=
"位置信息"
)
private
String
location
;
/**
* 单警柜号
*/
@ApiModelProperty
(
value
=
"单警柜号"
)
private
String
serverNum
;
private
Integer
state
;
/**
* 在线状态
*/
@ApiModelProperty
(
value
=
"在线状态"
)
private
Integer
onlineState
;
private
List
<
CabinetBoxDto
>
cabinetBoxList
;
...
...
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/query/CabinetReq.java
View file @
c0b8da71
...
...
@@ -15,15 +15,16 @@ public class CabinetReq extends BaseRequest {
/**
* 单警柜ID
*/
@NotNull
(
message
=
"单警柜ID主键不能为空"
,
groups
=
{
edit
.
class
,
delete
.
class
,
detail
.
class
})
@ApiModelProperty
(
value
=
"单警柜ID"
)
private
String
id
;
/**
* 单警柜编号
*/
@NotNull
(
message
=
"单警柜ID主键不能为空"
,
groups
=
{
edit
.
class
,
delete
.
class
,
detail
.
class
})
@ApiModelProperty
(
value
=
"单警柜编号"
)
private
String
cabinet
Num
;
private
String
serial
Num
;
/**
* 箱数
...
...
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/UpdateCabinetBoxReq.java
View file @
c0b8da71
...
...
@@ -7,20 +7,22 @@ import lombok.EqualsAndHashCode;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.util.List
;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
UpdateCabinetBoxReq
extends
BaseRequest
{
@NotBlank
(
message
=
"箱门id不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
})
//
@NotBlank(message = "箱门id不能为空",groups = {add.class,edit.class})
private
String
id
;
@NotNull
(
message
=
"箱门状态不能为空"
,
groups
=
{
edit
.
class
})
private
Integer
state
;
private
String
errorMsg
;
private
String
boxName
;
//单警柜编号
@NotBlank
(
message
=
"单警柜编号不能为空"
,
groups
=
{
add
.
class
})
private
String
cabinetNum
;
private
String
equipmentConfig
;
private
String
boxType
;
private
String
power
;
private
List
<
String
>
boxNum
;
private
Integer
num
;
}
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/UpdateCabinetReq.java
View file @
c0b8da71
...
...
@@ -25,13 +25,7 @@ public class UpdateCabinetReq extends BaseRequest {
*/
@NotBlank
(
message
=
"单警柜编号不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
,
detail
.
class
})
@ApiModelProperty
(
value
=
"单警柜编号"
)
private
String
cabinetNum
;
/**
* 箱数
*/
@ApiModelProperty
(
value
=
"箱数"
)
private
Integer
num
;
private
String
serialNum
;
/**
* 单警柜名称
...
...
@@ -39,6 +33,11 @@ public class UpdateCabinetReq extends BaseRequest {
@NotBlank
(
message
=
"单警柜名称不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
,
detail
.
class
})
@ApiModelProperty
(
value
=
"单警柜名称"
)
private
String
name
;
/**
* 单警柜名称
*/
@ApiModelProperty
(
value
=
"动作来源"
)
private
String
actionFrom
;
/**
* 组织机构号
...
...
@@ -50,7 +49,7 @@ public class UpdateCabinetReq extends BaseRequest {
/**
* 位置信息
*/
@NotBlank
(
message
=
"位置信息不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
})
@ApiModelProperty
(
value
=
"位置信息"
)
private
String
location
;
...
...
@@ -88,6 +87,8 @@ public class UpdateCabinetReq extends BaseRequest {
//箱门信息列表
private
List
<
UpdateCabinetBoxReq
>
cabinetBoxList
;
//箱门信息列表
private
List
<
String
>
numList
;
//单警柜id列表
private
List
<
String
>
cabinetList
;
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/controller/CabinetBoxController.java
View file @
c0b8da71
package
com
.
junmp
.
jyzb
.
controller
;
import
com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq
;
import
com.junmp.jyzb.api.bean.req.UpdateCabinetReq
;
import
com.junmp.jyzb.service.CabinetBoxService
;
import
com.junmp.v2.common.bean.request.ValidationApi
;
import
com.junmp.v2.common.bean.response.ApiRes
;
...
...
@@ -25,7 +26,14 @@ public class CabinetBoxController {
//添加箱门信息
@PostMapping
(
"/AddBoxInfo"
)
@ApiOperation
(
"添加箱门信息"
)
public
ApiRes
<
String
>
AddBoxInfo
(
@RequestBody
@Validated
(
ValidationApi
.
add
.
class
)
UpdateCabinetBoxReq
req
){
return
ApiRes
.
success
(
cabinetBoxService
.
AddBoxInfo
(
req
));
public
ApiRes
<
String
>
AddOrUpdateBoxInfo
(
@RequestBody
UpdateCabinetReq
req
){
return
ApiRes
.
success
(
cabinetBoxService
.
AddOrUpdateBoxInfo
(
req
));
}
//添加箱门信息
@PostMapping
(
"/DeleteBox"
)
@ApiOperation
(
"删除箱门"
)
public
ApiRes
<
String
>
DeleteBox
(
@RequestBody
@Validated
(
ValidationApi
.
delete
.
class
)
UpdateCabinetReq
req
){
return
ApiRes
.
success
(
cabinetBoxService
.
DeleteBox
(
req
));
}
}
jyzb-biz/src/main/java/com/junmp/jyzb/controller/CabinetController.java
View file @
c0b8da71
...
...
@@ -59,9 +59,9 @@ public class CabinetController {
return
ApiRes
.
success
(
cabinetService
.
deleteCabinetInfo
(
req
));
}
@PostMapping
(
"/UpdateCabinet
Info
"
)
@ApiOperation
(
"修改单警柜信息"
)
public
ApiRes
<
Boolean
>
updateCabinetInfo
(
@RequestBody
UpdateCabinetReq
req
)
{
@PostMapping
(
"/UpdateCabinet
Server
"
)
@ApiOperation
(
"修改单警柜信息
,平台使用
"
)
public
ApiRes
<
Boolean
>
UpdateCabinetServer
(
@RequestBody
UpdateCabinetReq
req
)
{
boolean
result
=
cabinetService
.
updateCabinetInfo
(
req
);
if
(!
result
){
return
ApiRes
.
failure
(
"操作失败"
);
...
...
@@ -69,7 +69,15 @@ public class CabinetController {
return
ApiRes
.
success
(
result
);
}
@PostMapping
(
"/UpdateCabinetClient"
)
@ApiOperation
(
"修改单警柜信息,警柜使用"
)
public
ApiRes
<
Boolean
>
UpdateCabinetClient
(
@RequestBody
UpdateCabinetReq
req
)
{
boolean
result
=
cabinetService
.
updateCabinetInfo
(
req
);
if
(!
result
){
return
ApiRes
.
failure
(
"操作失败"
);
}
return
ApiRes
.
success
(
result
);
}
//通过单警柜id查询单个箱门及其箱门信息
@PostMapping
(
"/ShowOneCabinet"
)
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/entity/Cabinet.java
View file @
c0b8da71
...
...
@@ -62,7 +62,12 @@ public class Cabinet implements Serializable {
*/
@ApiModelProperty
(
value
=
"单警柜当前状态,0正常,1异常"
)
private
Integer
state
;
/**
* 单警柜在线状态,0正常,1异常
*/
@ApiModelProperty
(
value
=
"单警柜在线状态,0离线,1在线"
)
@TableField
(
"online_state"
)
private
Integer
onlineState
;
/**
* 装备总数
*/
...
...
@@ -90,20 +95,13 @@ public class Cabinet implements Serializable {
@TableField
(
"price_total"
)
private
BigDecimal
priceTotal
;
/**
* 创建时间
*/
@ApiModelProperty
(
value
=
"创建时间"
)
@TableField
(
value
=
"create_time"
)
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
,
value
=
"create_time"
)
private
Date
createTime
;
/**
* 更新时间
*/
@ApiModelProperty
(
value
=
"更新时间"
)
@TableField
(
value
=
"update_time"
)
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
,
value
=
"update_time"
)
private
Date
updateTime
;
/**
* 新增人员
*/
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/entity/CabinetBox.java
View file @
c0b8da71
package
com
.
junmp
.
jyzb
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.*
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serializable
;
import
java.util.Date
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
...
...
@@ -38,6 +37,19 @@ public class CabinetBox implements Serializable {
private
Integer
num
;
/**
* 装备配置信息
*/
@ApiModelProperty
(
value
=
"装备配置信息"
)
@TableField
(
"equipment_config"
)
private
String
equipmentConfig
;
/**
* 功率
*/
@ApiModelProperty
(
value
=
"power"
)
@TableField
(
"power"
)
private
String
power
;
/**
* 异常状态:1正常/0异常
*/
@ApiModelProperty
(
value
=
"异常状态:1正常/0异常"
)
...
...
@@ -49,7 +61,18 @@ public class CabinetBox implements Serializable {
@ApiModelProperty
(
value
=
"异常原因"
)
@TableField
(
"error_msg"
)
private
String
errorMsg
;
/**
* 别名
*/
@ApiModelProperty
(
value
=
"别名"
)
@TableField
(
"box_name"
)
private
String
boxName
;
/**
* 箱门类型:1单警柜,2公共柜
*/
@ApiModelProperty
(
value
=
"箱门类型:1单警柜,2公共柜"
)
@TableField
(
"box_type"
)
private
String
boxType
;
/**
* 使用日志存储位置信息
*/
...
...
@@ -58,4 +81,10 @@ public class CabinetBox implements Serializable {
private
String
logMap
;
private
static
final
long
serialVersionUID
=
1L
;
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
,
value
=
"create_time"
)
private
Date
createTime
;
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
,
value
=
"update_time"
)
private
Date
updateTime
;
}
\ No newline at end of file
jyzb-biz/src/main/java/com/junmp/jyzb/service/CabinetBoxService.java
View file @
c0b8da71
...
...
@@ -3,6 +3,7 @@ package com.junmp.jyzb.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.junmp.jyzb.api.bean.query.CabinetReq
;
import
com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq
;
import
com.junmp.jyzb.api.bean.req.UpdateCabinetReq
;
import
com.junmp.jyzb.entity.CabinetBox
;
import
com.junmp.jyzb.entity.Policeman
;
...
...
@@ -13,8 +14,9 @@ public interface CabinetBoxService extends IService<CabinetBox> {
//添加箱门信息
String
AddBoxInfo
(
UpdateCabinetBoxReq
req
);
String
AddOrUpdateBoxInfo
(
UpdateCabinetReq
req
);
//添加箱门信息
String
DeleteBox
(
UpdateCabinetReq
req
);
//判断箱门信息是否存在
CabinetBox
CabinetBoxExist
(
String
id
);
}
jyzb-biz/src/main/java/com/junmp/jyzb/service/CabinetService.java
View file @
c0b8da71
...
...
@@ -46,13 +46,19 @@ public interface CabinetService extends IService<Cabinet> {
CabinetDto
showOneCabinet
(
CabinetReq
req
);
/**
* 修改单警柜信息
* 修改单警柜信息
,平台使用
* @param req
* @return
*/
boolean
updateCabinetInfo
(
UpdateCabinetReq
req
);
/**
* 修改单警柜信息,警柜使用
* @param req
* @return
*/
boolean
updateCabinetClient
(
UpdateCabinetReq
req
);
/**
* 箱门绑定人员
* @param req
* @return
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/CabinetBoxServiceImpl.java
View file @
c0b8da71
...
...
@@ -5,23 +5,32 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.junmp.jyzb.api.bean.query.CabinetReq
;
import
com.junmp.jyzb.api.bean.req.UpdateCabinetBoxReq
;
import
com.junmp.jyzb.api.bean.req.UpdateCabinetReq
;
import
com.junmp.jyzb.entity.Cabinet
;
import
com.junmp.jyzb.entity.CabinetBox
;
import
com.junmp.jyzb.api.exception.enums.CabinetBoxExceptionEnum
;
import
com.junmp.jyzb.api.exception.enums.CabinetExceptionEnum
;
import
com.junmp.jyzb.entity.ES.Blog
;
import
com.junmp.jyzb.mapper.CabinetBoxMapper
;
import
com.junmp.jyzb.mapper.PoliceFingerMapper
;
import
com.junmp.jyzb.mapper.PolicemanMapper
;
import
com.junmp.jyzb.service.CabinetBoxService
;
import
com.junmp.jyzb.service.CabinetService
;
import
com.junmp.jyzb.utils.RabbitMQSendMsg
;
import
com.junmp.v2.common.exception.base.ServiceException
;
import
com.junmp.v2.common.util.BeanPlusUtil
;
import
org.apache.poi.ss.formula.functions.Now
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Service
public
class
CabinetBoxServiceImpl
extends
ServiceImpl
<
CabinetBoxMapper
,
CabinetBox
>
implements
CabinetBoxService
{
...
...
@@ -29,15 +38,77 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
@Resource
private
CabinetService
cabinetService
;
@Autowired
private
RabbitMQSendMsg
MQ
;
//添加箱门信息
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
AddBoxInfo
(
UpdateCabinetBoxReq
req
)
{
public
String
AddOrUpdateBoxInfo
(
UpdateCabinetReq
req
)
{
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
req
.
getSerialNum
()));
if
(
ObjectUtil
.
isNull
(
cabinet
))
{
throw
new
ServiceException
(
CabinetExceptionEnum
.
CABINET_ISNOT_EXISTS
);
}
List
<
UpdateCabinetBoxReq
>
addList
=
req
.
getCabinetBoxList
();
List
<
CabinetBox
>
existingBoxes
=
list
(
new
LambdaQueryWrapper
<
CabinetBox
>()
.
eq
(
CabinetBox:
:
getCabinetId
,
cabinet
.
getId
()));
Map
<
Integer
,
CabinetBox
>
existingBoxMap
=
existingBoxes
.
stream
()
.
collect
(
Collectors
.
toMap
(
CabinetBox:
:
getNum
,
Function
.
identity
()));
List
<
CabinetBox
>
boxListAdd
=
new
ArrayList
<>();
for
(
UpdateCabinetBoxReq
boxReq
:
addList
)
{
CabinetBox
box
=
new
CabinetBox
();
box
.
setCabinetId
(
cabinet
.
getId
());
box
.
setPower
(
boxReq
.
getPower
());
box
.
setEquipmentConfig
(
boxReq
.
getEquipmentConfig
());
box
.
setBoxType
(
boxReq
.
getBoxType
());
box
.
setState
(
0
);
box
.
setBoxName
(
boxReq
.
getBoxName
());
box
.
setNum
(
boxReq
.
getNum
());
box
.
setUpdateTime
(
new
Date
());
// 在内存中比较是否存在相同 SerialNum 和相同 num 的数据
CabinetBox
existingBox
=
existingBoxMap
.
get
(
boxReq
.
getNum
());
if
(
existingBox
!=
null
)
{
// 如果存在,则更新数据
box
.
setId
(
existingBox
.
getId
());
updateById
(
box
);
}
else
{
// 如果不存在,则新增数据
boxListAdd
.
add
(
box
);
}
}
Integer
num
=
cabinet
.
getNum
();
//获取当前柜的总数量
if
(
num
==
null
)
{
num
=
0
;
}
// 更新 Cabinet 实体
cabinet
.
setNum
(
num
+
addList
.
size
());
cabinetService
.
updateById
(
cabinet
);
if
(
req
.
getActionFrom
().
equals
(
"platform"
))
//请求来源于平台,则进行推送
{
MQ
.
SendMsg
(
"cabinetMsg"
,
req
.
getSerialNum
(),
"cabinetChange"
);
}
// 批量保存新增的数据
saveBatch
(
boxListAdd
);
return
cabinet
.
getId
();
}
//删除箱门
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
DeleteBox
(
UpdateCabinetReq
req
)
{
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
req
.
get
Cabinet
Num
()));
.
eq
(
Cabinet:
:
getCabinetNum
,
req
.
get
Serial
Num
()));
if
(
ObjectUtil
.
isNull
(
cabinet
)){
throw
new
ServiceException
(
CabinetExceptionEnum
.
CABINET_ISNOT_EXISTS
);
}
...
...
@@ -47,26 +118,24 @@ public class CabinetBoxServiceImpl extends ServiceImpl<CabinetBoxMapper, Cabinet
if
(
ObjectUtil
.
isNotNull
(
one
)){
throw
new
ServiceException
(
CabinetBoxExceptionEnum
.
CABINETBOX_IS_EXISTS
);
}
CabinetBoxExist
(
req
.
getId
());
CabinetBox
cabinetBox
=
new
CabinetBox
();
BeanPlusUtil
.
copyProperties
(
req
,
cabinetBox
);
//添加单警柜箱门信息默认状态为0正常
cabinetBox
.
setState
(
0
);
cabinetBox
.
setCabinetId
(
cabinet
.
getId
());
Integer
num
=
cabinet
.
getNum
();
if
(
num
==
null
){
num
=
1
;
cabinet
.
setNum
(
num
);
cabinetBox
.
setNum
(
num
);
}
else
{
cabinet
.
setNum
(
num
+
1
);
cabinet
Box
.
setNum
(
num
+
1
);
List
<
String
>
boxNumList
=
req
.
getNumList
(
);
remove
(
new
LambdaQueryWrapper
<
CabinetBox
>()
.
eq
(
CabinetBox:
:
getCabinetId
,
cabinet
.
getId
())
.
in
(
CabinetBox:
:
getNum
,
boxNumList
));
// 更新 Cabinet 实体的 num 字段
Integer
cabinetNum
=
cabinet
.
getNum
(
);
if
(
cabinetNum
!=
null
)
{
cabinet
.
setNum
(
cabinetNum
-
boxNumList
.
size
()
);
cabinet
Service
.
updateById
(
cabinet
);
}
cabinetService
.
updateById
(
cabinet
);
save
(
cabinetBox
);
return
cabinetBox
.
getId
();
if
(
req
.
getActionFrom
().
equals
(
"platform"
))
//请求来源于平台,则进行推送
{
MQ
.
SendMsg
(
"cabinetMsg"
,
req
.
getSerialNum
(),
"cabinetChange"
);
}
return
cabinet
.
getId
();
}
//判断箱子信息是否存在
@Override
public
CabinetBox
CabinetBoxExist
(
String
id
)
{
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/CabinetServiceImpl.java
View file @
c0b8da71
差异被折叠。
点击展开。
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/OrderMainServiceImpl.java
View file @
c0b8da71
...
...
@@ -21,6 +21,8 @@ import com.junmp.jyzb.entity.*;
import
com.junmp.jyzb.mapper.OrderMainMapper
;
import
com.junmp.jyzb.service.*
;
import
com.junmp.jyzb.utils.DateTimeUtil
;
import
com.junmp.jyzb.utils.RabbitMQSendMsg
;
import
com.junmp.jyzb.utils.RedisUtils
;
import
com.junmp.v2.common.bean.response.ApiRes
;
import
com.junmp.v2.common.exception.base.ServiceException
;
import
com.junmp.v2.common.exception.enums.DefaultBizExceptionEnum
;
...
...
@@ -41,6 +43,7 @@ import org.springframework.amqp.core.Queue;
import
org.springframework.amqp.rabbit.core.RabbitAdmin
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.amqp.core.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -108,6 +111,8 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
@Resource
protected
TaskService
taskService
;
@Autowired
private
RabbitMQSendMsg
MQ
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
@@ -285,29 +290,13 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
}
//将完成的任务单直接推送到消息队列rabbitmq中(需要判断是入库单还是出库单,入库单传发物单位id,出库单传收物单位id)
//方法1:一个交换机,一个队列。通过中间对象,object存储对象,type表标识
// if(req.getOrderType().equals("in")){
// rabbitTemplate.convertAndSend("OrderExchange","OrderRouting",new MessageWrapper(req,req.getStartOrgId()));
// }else {
// rabbitTemplate.convertAndSend("OrderExchange","OrderRouting",new MessageWrapper(req,req.getEndOrgId()));
// }
//方法2:一个交换机,多个队列。动态创建队列
String
exchangeName
=
"orderExchange"
;
//需要判断是入库单还是出库单,入库单传收物单位id,出库单传发物单位id
if
(
req
.
getOrderType
().
equals
(
"in"
)){
Queue
queue
=
new
Queue
(
req
.
getEndOrgId
().
toString
(),
true
,
false
,
false
);
Exchange
exchange
=
new
DirectExchange
(
exchangeName
,
true
,
false
);
rabbitAdmin
.
declareQueue
(
queue
);
rabbitAdmin
.
declareExchange
(
exchange
);
rabbitAdmin
.
declareBinding
(
BindingBuilder
.
bind
(
queue
).
to
(
exchange
).
with
(
req
.
getEndOrgId
().
toString
()).
noargs
());
rabbitTemplate
.
convertAndSend
(
exchangeName
,
req
.
getEndOrgId
().
toString
(),
req
);
MQ
.
SendMsg
(
exchangeName
,
req
.
getEndOrgId
().
toString
(),
req
);
}
else
{
Queue
queue
=
new
Queue
(
req
.
getStartOrgId
().
toString
(),
true
,
false
,
false
);
Exchange
exchange
=
new
DirectExchange
(
exchangeName
,
true
,
false
);
rabbitAdmin
.
declareQueue
(
queue
);
rabbitAdmin
.
declareExchange
(
exchange
);
rabbitAdmin
.
declareBinding
(
BindingBuilder
.
bind
(
queue
).
to
(
exchange
).
with
(
req
.
getStartOrgId
().
toString
()).
noargs
());
rabbitTemplate
.
convertAndSend
(
exchangeName
,
req
.
getStartOrgId
().
toString
(),
req
);
MQ
.
SendMsg
(
exchangeName
,
req
.
getStartOrgId
().
toString
(),
req
);
}
return
req
.
getId
();
}
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/utils/RabbitMQSendMsg.java
0 → 100644
View file @
c0b8da71
package
com
.
junmp
.
jyzb
.
utils
;
import
org.springframework.amqp.core.BindingBuilder
;
import
org.springframework.amqp.core.DirectExchange
;
import
org.springframework.amqp.core.Exchange
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.amqp.rabbit.core.RabbitAdmin
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
RabbitMQSendMsg
{
@Resource
private
RabbitTemplate
rabbitTemplate
;
@Resource
private
RabbitAdmin
rabbitAdmin
;
public
void
SendMsg
(
String
exchangeName
,
String
name
,
Object
msg
)
{
Queue
queue
=
new
Queue
(
name
,
true
,
false
,
false
);
Exchange
exchange
=
new
DirectExchange
(
exchangeName
,
true
,
false
);
rabbitAdmin
.
declareQueue
(
queue
);
rabbitAdmin
.
declareExchange
(
exchange
);
rabbitAdmin
.
declareBinding
(
BindingBuilder
.
bind
(
queue
).
to
(
exchange
).
with
(
name
).
noargs
());
rabbitTemplate
.
convertAndSend
(
exchangeName
,
name
,
msg
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论