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
c1549f9e
Commit
c1549f9e
authored
Jan 22, 2024
by
李小惠
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
http://gitlab.sothing.top/843502640/jyzb_platformV2
into develop-lxh
parents
30167ba0
0663c56b
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
964 行增加
和
51 行删除
+964
-51
pom.xml
jyzb-api/pom.xml
+4
-0
CabinetPoliceDto.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/CabinetPoliceDto.java
+17
-0
PoliceDetailDto.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/PoliceDetailDto.java
+19
-0
PolicemanReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/query/PolicemanReq.java
+1
-0
CabinetDataList.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/CabinetDataList.java
+18
-0
CabinetPolicemanReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/CabinetPolicemanReq.java
+44
-0
CabinetUploadReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/CabinetUploadReq.java
+22
-0
PoliceListReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/PoliceListReq.java
+26
-0
UpdatePolicemanReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/UpdatePolicemanReq.java
+2
-0
OnOpenReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/wsReq/OnOpenReq.java
+26
-0
JYZBConstant.java
jyzb-api/src/main/java/com/junmp/jyzb/api/constant/JYZBConstant.java
+5
-0
UserExceptionEnum.java
jyzb-api/src/main/java/com/junmp/jyzb/api/exception/enums/UserExceptionEnum.java
+5
-1
OnlineRedisCache.java
jyzb-biz/src/main/java/com/junmp/jyzb/cache/OnlineRedisCache.java
+71
-0
PoliceController.java
jyzb-biz/src/main/java/com/junmp/jyzb/controller/PoliceController.java
+33
-1
PubOrg.java
jyzb-biz/src/main/java/com/junmp/jyzb/entity/PubOrg.java
+12
-1
OnlineState.java
jyzb-biz/src/main/java/com/junmp/jyzb/entity/Temp/OnlineState.java
+16
-0
PolicemanService.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/PolicemanService.java
+9
-6
PolicemanServiceImpl.java
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/PolicemanServiceImpl.java
+393
-42
RabbitMQSendMsg.java
jyzb-biz/src/main/java/com/junmp/jyzb/utils/RabbitMQSendMsg.java
+6
-0
CustomScreenWebSocketServer.java
jyzb-biz/src/main/java/com/junmp/jyzb/websocket/CustomScreenWebSocketServer.java
+218
-0
ActivitiConfig.java
jyzb-process/src/main/java/com/junmp/junmpProcess/config/ActivitiConfig.java
+1
-0
pom.xml
pom.xml
+16
-0
没有找到文件。
jyzb-api/pom.xml
View file @
c1549f9e
...
...
@@ -53,6 +53,10 @@
<version>
2.5.0
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-annotations
</artifactId>
</dependency>
</dependencies>
</project>
...
...
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/CabinetPoliceDto.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
api
.
bean
.
dto
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
CabinetPoliceDto
{
private
String
orgId
;
private
String
orgName
;
private
String
ActionUpdateTime
;
private
String
lastAction
;
private
List
<
PoliceDetailDto
>
policeList
;
}
\ No newline at end of file
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/dto/PoliceDetailDto.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
api
.
bean
.
dto
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
PoliceDetailDto
{
private
String
id
;
private
String
name
;
private
String
finger
;
private
String
policeCode
;
private
String
photo
;
private
String
cabinetName
;
private
String
serialNum
;
private
List
<
String
>
boxList
;
}
\ No newline at end of file
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/query/PolicemanReq.java
View file @
c1549f9e
...
...
@@ -19,6 +19,7 @@ public class PolicemanReq extends BaseRequest {
@NotBlank
(
message
=
"姓名不能为空"
)
private
String
name
;
private
List
<
String
>
orgList
;
private
String
cabinetId
;
private
List
<
String
>
boxList
;
...
...
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/CabinetDataList.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
api
.
bean
.
req
;
import
com.junmp.v2.common.bean.request.BaseRequest
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
public
class
CabinetDataList
{
private
String
orgId
;
List
<
PoliceListReq
>
policeList
;
}
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/CabinetPolicemanReq.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
api
.
bean
.
req
;
import
com.junmp.v2.common.bean.request.BaseRequest
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
import
java.util.List
;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
CabinetPolicemanReq
extends
BaseRequest
{
@NotBlank
(
message
=
"警员主键不能为空"
,
groups
=
{
edit
.
class
,
delete
.
class
,
detail
.
class
})
private
String
policeId
;
@NotBlank
(
message
=
"警员名字不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
})
private
String
name
;
private
String
cabinetOrgId
;
private
String
currentCabinetId
;
@NotNull
(
message
=
"组织机构id不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
})
private
Long
orgId
;
@NotBlank
(
message
=
"警员编号不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
})
private
String
policeCode
;
@NotBlank
(
message
=
"人脸信息不能为空"
,
groups
=
{
detail
.
class
})
private
String
photo
;
@NotBlank
(
message
=
"主柜不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
})
private
String
serialNum
;
/**
* 指纹list
*/
private
String
finger
;
private
List
<
Long
>
RolesList
;
}
\ No newline at end of file
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/CabinetUploadReq.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
api
.
bean
.
req
;
import
com.junmp.v2.common.bean.request.BaseRequest
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.util.List
;
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
CabinetUploadReq
extends
BaseRequest
{
private
String
cabinetOrgId
;
private
String
serialNum
;
private
List
<
CabinetDataList
>
dataList
;
}
\ No newline at end of file
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/PoliceListReq.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
api
.
bean
.
req
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
PoliceListReq
{
private
String
policeID
;
private
String
policeCode
;
private
String
cabinetBoxId
;
private
String
photo
;
private
String
name
;
private
String
finger
;
// /**
// * 角色id列表
// */
private
List
<
Long
>
rolesList
;
}
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/UpdatePolicemanReq.java
View file @
c1549f9e
...
...
@@ -19,7 +19,9 @@ public class UpdatePolicemanReq extends BaseRequest {
@NotBlank
(
message
=
"警员名字不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
})
private
String
name
;
private
String
cabinetOrgId
;
private
String
currentCabinetId
;
@NotNull
(
message
=
"组织机构id不能为空"
,
groups
=
{
add
.
class
,
edit
.
class
})
private
Long
orgId
;
...
...
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/wsReq/OnOpenReq.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
api
.
bean
.
req
.
wsReq
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Data
;
@Data
public
class
OnOpenReq
{
/**
*
*/
private
String
type
;
/**
*
*/
private
String
typeId
;
// 有参构造函数
public
OnOpenReq
(
@JsonProperty
(
"type"
)
String
type
,
@JsonProperty
(
"typeId"
)
String
typeId
)
{
this
.
type
=
type
;
this
.
typeId
=
typeId
;
}
}
jyzb-api/src/main/java/com/junmp/jyzb/api/constant/JYZBConstant.java
View file @
c1549f9e
...
...
@@ -35,5 +35,10 @@ public interface JYZBConstant {
*/
String
JYZB_TEMP_PREFIX
=
"temp:"
;
/**
* 设备状态前缀
*/
String
JYZB_ONLINE_PREFIX
=
"onlineState:"
;
String
JYZB_JWT_KEY
=
"JWT"
;
}
jyzb-api/src/main/java/com/junmp/jyzb/api/exception/enums/UserExceptionEnum.java
View file @
c1549f9e
...
...
@@ -9,7 +9,11 @@ public enum UserExceptionEnum implements IExceptionEnum {
/**
* 账号已存在
*/
USER_IS_EXIST
(
CommonConstant
.
DEFAULT_USER_ERROR_CODE
,
"账号已存在"
)
USER_IS_EXIST
(
CommonConstant
.
DEFAULT_USER_ERROR_CODE
,
"账号已存在"
),
/**
* 账号已存在
*/
POLICE_IS_EXIST
(
CommonConstant
.
DEFAULT_USER_ERROR_CODE
,
"警员已存在"
)
;
/**
* 错误编码
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/cache/OnlineRedisCache.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
cache
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.junmp.jyzb.api.constant.JYZBConstant
;
import
com.junmp.jyzb.entity.Temp.HumidityAndtemperature
;
import
com.junmp.jyzb.entity.Temp.OnlineState
;
import
com.junmp.v2.cache.AbstractRedisCache
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
@Component
public
class
OnlineRedisCache
extends
AbstractRedisCache
<
Object
>
{
public
OnlineRedisCache
(
RedisTemplate
<
String
,
Object
>
redisTemplate
)
{
super
(
redisTemplate
);
}
@Override
public
String
getCommonKeyPrefix
()
{
return
JYZBConstant
.
JYZB_ONLINE_PREFIX
;
}
public
void
addSessionValue
(
String
type
,
String
sessionId
,
String
typeId
,
long
temperature
)
{
OnlineState
data
=
new
OnlineState
();
data
.
setType
(
type
);
data
.
setTypeId
(
typeId
);
String
key
=
sessionId
;
String
jsonData
;
// 将OnlineState对象转换为JSON字符串
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
jsonData
=
objectMapper
.
writeValueAsString
(
data
);
}
catch
(
Exception
e
)
{
// 处理转换异常
e
.
printStackTrace
();
return
;
}
getRedisTemplate
().
opsForValue
().
set
(
key
,
jsonData
);
put
(
key
,
data
);
}
public
OnlineState
getDataValue
(
String
sessionId
)
{
boolean
exists
=
getRedisTemplate
().
hasKey
(
sessionId
);
if
(!
exists
)
{
// 处理不存在的情况
return
null
;
}
Set
<
Object
>
dataInRange
=
getRedisTemplate
().
opsForZSet
().
range
(
sessionId
,
0
,
-
1
);
// 如果集合非空,返回第一个元素,否则返回null
if
(!
dataInRange
.
isEmpty
())
{
Object
firstElement
=
dataInRange
.
iterator
().
next
();
// 检查类型是否为 OnlineState
if
(
firstElement
instanceof
OnlineState
)
{
return
(
OnlineState
)
firstElement
;
// 执行强制类型转换
}
else
{
// 处理类型不匹配的情况
return
null
;
}
}
else
{
return
null
;
}
}
}
jyzb-biz/src/main/java/com/junmp/jyzb/controller/PoliceController.java
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
controller
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.junmp.jyzb.api.bean.dto.CabinetPoliceDto
;
import
com.junmp.jyzb.api.bean.dto.FetchingDataDto.PoliceDto
;
import
com.junmp.jyzb.api.bean.dto.FetchingDataDto.UserDto
;
import
com.junmp.jyzb.api.bean.dto.PolicemanDto
;
...
...
@@ -8,6 +9,8 @@ import com.junmp.jyzb.api.bean.dto.ReassignmentDto;
import
com.junmp.jyzb.api.bean.query.CabinetReq
;
import
com.junmp.jyzb.api.bean.query.PolicemanReq
;
import
com.junmp.jyzb.api.bean.query.QueryReassignmentReq
;
import
com.junmp.jyzb.api.bean.req.CabinetPolicemanReq
;
import
com.junmp.jyzb.api.bean.req.CabinetUploadReq
;
import
com.junmp.jyzb.api.bean.req.UpdatePolicemanReq
;
import
com.junmp.jyzb.api.bean.req.UpdateReassignmentReq
;
import
com.junmp.jyzb.entity.EquipmentSize
;
...
...
@@ -50,6 +53,12 @@ public class PoliceController {
String
policeId
=
policemanService
.
AddPoliceman
(
req
);
return
ApiRes
.
success
(
policeId
);
}
@PostMapping
(
path
=
"/AddPolicemanFromCab"
,
name
=
"添加警员信息(单警柜使用)#logType=30"
)
@ApiOperation
(
"添加警员信息"
)
public
ApiRes
<
String
>
AddPolicemanFromCab
(
@RequestBody
@Validated
(
ValidationApi
.
add
.
class
)
CabinetPolicemanReq
req
)
{
String
policeId
=
policemanService
.
AddPolicemanFromCab
(
req
);
return
ApiRes
.
success
(
policeId
);
}
//添加警员时先将没有组织机构号的警员查询出来
@PostMapping
(
path
=
"/GetPoliceWithoutOrg"
,
name
=
"获取没有组织机构的警员信息#enable"
)
@ApiOperation
(
"/获取没有组织机构的警员信息"
)
...
...
@@ -94,6 +103,24 @@ public class PoliceController {
}
return
ApiRes
.
success
(
b
);
}
@PostMapping
(
path
=
"/UploadPolicemanList"
,
name
=
"上传当前所有警员信息#logType=30"
)
@ApiOperation
(
"上传当前所有警员信息"
)
public
ApiRes
<
Boolean
>
UploadPolicemanList
(
@RequestBody
@Validated
(
ValidationApi
.
edit
.
class
)
CabinetUploadReq
req
)
{
boolean
b
=
policemanService
.
UploadPolicemanList
(
req
);
if
(!
b
){
return
ApiRes
.
failure
(
"修改失败"
);
}
return
ApiRes
.
success
(
b
);
}
@PostMapping
(
path
=
"/UpdatePoliceFromCab"
,
name
=
"修改警员信息(警柜使用)#logType=30"
)
@ApiOperation
(
"修改警员信息"
)
public
ApiRes
<
Boolean
>
UpdatePoliceFromCab
(
@RequestBody
@Validated
(
ValidationApi
.
edit
.
class
)
CabinetPolicemanReq
req
)
{
boolean
b
=
policemanService
.
UpdatePoliceFromCab
(
req
);
if
(!
b
){
return
ApiRes
.
failure
(
"修改失败"
);
}
return
ApiRes
.
success
(
b
);
}
//重置密码
@PostMapping
(
path
=
"/reSetPassword"
,
name
=
"重置密码#logType=30"
)
@ApiOperation
(
"重置密码"
)
...
...
@@ -117,7 +144,12 @@ public class PoliceController {
List
<
PolicemanDto
>
policemanDtos
=
policemanService
.
GetAllPolicemanList
(
req
);
return
ApiRes
.
success
(
policemanDtos
);
}
@PostMapping
(
path
=
"/GetListByOrg"
,
name
=
"根据组织机构查询对应警员信息(警柜使用)#enable"
)
@ApiOperation
(
"根据组织机构查询对应警员信息(警柜使用)"
)
public
ApiRes
<
List
<
CabinetPoliceDto
>>
GetListByOrg
(
@RequestBody
PolicemanReq
req
){
List
<
CabinetPoliceDto
>
policemanDtos
=
policemanService
.
GetListByOrgAsync
(
req
);
return
ApiRes
.
success
(
policemanDtos
);
}
//根据组条件查询,只查询本级,不包含下级(page)--可以根据组织机构查询
@PostMapping
(
path
=
"/ShowPolicePage"
,
name
=
"根据条件查询所有警员信息#enable"
)
@ApiOperation
(
"根据条件查询所有警员信息(page)"
)
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/entity/PubOrg.java
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
entity
;
import
cn.hutool.core.date.DateTime
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
...
...
@@ -210,6 +211,15 @@ public class PubOrg implements Serializable {
*/
@TableField
(
value
=
"org_name"
)
private
String
orgName
;
/**
* 最后的警员信息更新终端
*/
@TableField
(
value
=
"police_update_service"
)
private
String
policeUpdateService
;
/**
* 最后警员信息更新时间
*/
@TableField
(
value
=
"police_update_time"
)
private
Date
policeUpdateTime
;
}
\ No newline at end of file
jyzb-biz/src/main/java/com/junmp/jyzb/entity/Temp/OnlineState.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
entity
.
Temp
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.springframework.context.annotation.Configuration
;
@Data
@Configuration
@NoArgsConstructor
public
class
OnlineState
{
//类型
private
String
type
;
//类型ID
private
String
typeId
;
}
jyzb-biz/src/main/java/com/junmp/jyzb/service/PolicemanService.java
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.junmp.jyzb.api.bean.dto.CabinetPoliceDto
;
import
com.junmp.jyzb.api.bean.dto.FetchingDataDto.PoliceDto
;
import
com.junmp.jyzb.api.bean.dto.FetchingDataDto.UserDto
;
import
com.junmp.jyzb.api.bean.dto.PolicemanDto
;
...
...
@@ -9,9 +10,7 @@ import com.junmp.jyzb.api.bean.dto.UploadPolicePhotoDto;
import
com.junmp.jyzb.api.bean.query.CabinetReq
;
import
com.junmp.jyzb.api.bean.query.PolicemanReq
;
import
com.junmp.jyzb.api.bean.query.QueryReassignmentReq
;
import
com.junmp.jyzb.api.bean.req.UpdatePolicemanReq
;
import
com.junmp.jyzb.api.bean.req.UpdateReassignmentReq
;
import
com.junmp.jyzb.api.bean.req.UploadPolicePhotoReq
;
import
com.junmp.jyzb.api.bean.req.*
;
import
com.junmp.jyzb.entity.PoliceEquipment
;
import
com.junmp.jyzb.entity.Policeman
;
import
com.junmp.jyzb.entity.Reassignment
;
...
...
@@ -30,7 +29,8 @@ public interface PolicemanService extends IService<Policeman> {
//添加警员
String
AddPoliceman
(
UpdatePolicemanReq
req
);
//添加警员,警柜使用
String
AddPolicemanFromCab
(
CabinetPolicemanReq
req
);
//获取单个警员信息
PolicemanDto
GetOnePolice
(
PolicemanReq
req
);
...
...
@@ -42,9 +42,9 @@ public interface PolicemanService extends IService<Policeman> {
//修改警员信息
boolean
UpdatePolice
(
UpdatePolicemanReq
req
);
boolean
UpdatePoliceFromCab
(
CabinetPolicemanReq
req
);
boolean
UploadPolicemanList
(
CabinetUploadReq
req
);
boolean
AddFaceInfo
(
UpdatePolicemanReq
req
);
...
...
@@ -54,6 +54,9 @@ public interface PolicemanService extends IService<Policeman> {
//通过条件查询警员列表(list)
List
<
PolicemanDto
>
GetAllPolicemanList
(
PolicemanReq
req
);
//通过组织机构列表查询
List
<
CabinetPoliceDto
>
GetListByOrgAsync
(
PolicemanReq
req
);
//通过条件查询警员列表(page)
PageResult
<
PolicemanDto
>
GetAllPolicemanPage
(
PolicemanReq
req
);
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/service/impl/PolicemanServiceImpl.java
View file @
c1549f9e
...
...
@@ -23,9 +23,7 @@ import com.junmp.jyzb.api.bean.query.CabinetBoxReq;
import
com.junmp.jyzb.api.bean.query.CabinetReq
;
import
com.junmp.jyzb.api.bean.query.PolicemanReq
;
import
com.junmp.jyzb.api.bean.query.QueryReassignmentReq
;
import
com.junmp.jyzb.api.bean.req.UpdatePolicemanReq
;
import
com.junmp.jyzb.api.bean.req.UpdateReassignmentReq
;
import
com.junmp.jyzb.api.bean.req.UploadPolicePhotoReq
;
import
com.junmp.jyzb.api.bean.req.*
;
import
com.junmp.jyzb.api.exception.enums.*
;
import
com.junmp.jyzb.entity.*
;
import
com.junmp.jyzb.mapper.*
;
...
...
@@ -61,6 +59,7 @@ import com.junmp.v2.sys.user.service.SysUserOrgService;
import
com.junmp.v2.sys.user.service.SysUserRoleService
;
import
com.junmp.v2.sys.user.service.SysUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -71,6 +70,7 @@ import java.math.BigDecimal;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.concurrent.*
;
import
java.util.stream.Collectors
;
...
...
@@ -129,7 +129,8 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
@Resource
private
SysDictItemService
sysDictItemService
;
@Autowired
private
RabbitMQSendMsg
MQ
;
@Resource
private
InventorySummaryMapper
inventorySummaryMapper
;
...
...
@@ -196,10 +197,88 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
policeman
.
setCreateTime
(
DateTimeUtil
.
getCurrentDateTime
());
policeman
.
setUpdateTime
(
DateTimeUtil
.
getCurrentDateTime
());
save
(
policeman
);
PubOrg
orgInfo
=
pubOrgService
.
getOne
(
new
LambdaQueryWrapper
<
PubOrg
>().
eq
(
PubOrg:
:
getOrgId
,
req
.
getOrgId
()));
orgInfo
.
setPoliceUpdateTime
(
DateTimeUtil
.
getCurrentDateTime
());
orgInfo
.
setPoliceUpdateService
(
"平台"
);
pubOrgService
.
updateById
(
orgInfo
);
List
<
Cabinet
>
cabinets
=
cabinetService
.
list
(
new
LambdaQueryWrapper
<
Cabinet
>().
eq
(
Cabinet:
:
getOrgIdInt
,
req
.
getOrgId
()));
//拿到组织机构下所有的警柜用于消息推送
if
(
cabinets
.
size
()>
0
)
{
cabinets
.
forEach
(
t
->
MQ
.
SendMsg
(
"cabinetMsg"
,
t
.
getCabinetNum
(),
"policeChange"
));
}
//警员添加成功之后,往消息队列推送人员更新的消息
MQ
.
SendMsg
(
"warehouseMsg"
,
req
.
getOrgId
().
toString
(),
"policeChange"
);
//推送至仓库主机
return
policeman
.
getId
();
}
/**
* 添加警员信息
*
* @param req
* @return
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
AddPolicemanFromCab
(
CabinetPolicemanReq
req
)
{
//判断传入的用户名是否存在
Policeman
one
=
this
.
getOne
(
new
LambdaQueryWrapper
<
Policeman
>()
.
eq
(
Policeman:
:
getName
,
req
.
getName
())
.
and
(
wrapper
->
wrapper
.
eq
(
Policeman:
:
getPoliceCode
,
req
.
getPoliceCode
()))
);
if
(
one
!=
null
){
throw
new
ServiceException
(
UserExceptionEnum
.
POLICE_IS_EXIST
);
}
//查询传入的组织机构id是否存在
pubOrgService
.
PubOrgExist
(
req
.
getOrgId
());
//警柜添加的人员统一视为用户
String
UserRoleId
=
"1716370847267106817"
;
List
<
Long
>
roleList
=
new
ArrayList
<>();
roleList
.
add
(
Long
.
valueOf
(
UserRoleId
));
req
.
setRolesList
(
roleList
);
//绑定账号
SysUser
sysUser
=
addFromCabinet
(
req
);
//判断是否添加角色,进行绑定
List
<
SysUserRole
>
sysUserRoleList
=
new
ArrayList
<>()
;
if
(
req
.
getRolesList
().
size
()>
0
){
for
(
Long
roleId:
req
.
getRolesList
())
{
SysUserRole
sysUserRole
=
new
SysUserRole
();
sysUserRole
.
setRoleId
(
roleId
);
sysUserRole
.
setUserId
(
sysUser
.
getUserId
());
sysUserRole
.
setCreateTime
(
DateTimeUtil
.
getCurrentDateTime
());
// sysUserRole.setCreateUser(req.getCreateUser());
sysUserRoleList
.
add
(
sysUserRole
);
}
}
sysUserRoleService
.
saveBatch
(
sysUserRoleList
);
Policeman
policeman
=
new
Policeman
();
BeanPlusUtil
.
copyProperties
(
req
,
policeman
);
policeman
.
setId
(
req
.
getPoliceId
());
policeman
.
setPassword
(
sysUser
.
getPassword
());
policeman
.
setState
(
1
);
policeman
.
setUserId
(
sysUser
.
getUserId
());
policeman
.
setCreateTime
(
DateTimeUtil
.
getCurrentDateTime
());
policeman
.
setUpdateTime
(
DateTimeUtil
.
getCurrentDateTime
());
save
(
policeman
);
PubOrg
orgInfo
=
pubOrgService
.
getOne
(
new
LambdaQueryWrapper
<
PubOrg
>().
eq
(
PubOrg:
:
getOrgId
,
req
.
getOrgId
()));
orgInfo
.
setPoliceUpdateTime
(
DateTimeUtil
.
getCurrentDateTime
());
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>().
eq
(
Cabinet:
:
getCabinetNum
,
req
.
getSerialNum
()));
orgInfo
.
setPoliceUpdateService
(
cabinet
.
getName
()+
"-"
+
cabinet
.
getCabinetNum
());
pubOrgService
.
updateById
(
orgInfo
);
List
<
Cabinet
>
cabinets
=
cabinetService
.
list
(
new
LambdaQueryWrapper
<
Cabinet
>().
eq
(
Cabinet:
:
getOrgIdInt
,
req
.
getCabinetOrgId
()));
//拿到组织机构下所有的警柜用于消息推送
if
(
cabinets
.
size
()>
0
)
{
cabinets
.
forEach
(
t
->
MQ
.
SendMsg
(
"cabinetMsg"
,
t
.
getCabinetNum
(),
"policeChange"
));
}
//警员添加成功之后,往消息队列推送人员更新的消息
MQ
.
SendMsg
(
"warehouseMsg"
,
req
.
getOrgId
().
toString
(),
"policeChange"
);
//推送至仓库主机
return
policeman
.
getId
();
}
/**
* 警员绑定账号
...
...
@@ -207,6 +286,64 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
* @param
* @return
*/
public
SysUser
addFromCabinet
(
CabinetPolicemanReq
req
)
{
String
accountSet
=
""
;
//判断是否有重复的账号
SysUser
one
=
sysUserService
.
getOne
(
new
LambdaQueryWrapper
<
SysUser
>()
.
eq
(
SysUser:
:
getAccount
,
req
.
getName
()));
if
(
ObjectUtil
.
isNotNull
(
one
)){
//警员账号如果已存在,则账号改为姓名+警号
accountSet
=
req
.
getName
()+
req
.
getPoliceCode
();
}
else
{
accountSet
=
req
.
getName
();
}
SysUser
sysUser
=
new
SysUser
();
BeanPlusUtil
.
copyProperties
(
req
,
sysUser
);
sysUser
.
setAccount
(
accountSet
);
sysUser
.
setNickName
(
req
.
getName
());
sysUser
.
setRealName
(
req
.
getName
());
SysUserCreateFactory
.
fillAddSysUser
(
sysUser
);
sysUser
.
setAvatar
(
FileConstant
.
DEFAULT_AVATAR_FILE_ID
);
sysUser
.
setDelFlag
(
LogicDelEnum
.
N
.
getCode
());
sysUser
.
setCreateTime
(
DateTime
.
now
());
sysUser
.
setUpdateTime
(
DateTime
.
now
());
sysUserService
.
save
(
sysUser
);
sysUserOrgService
.
add
(
sysUser
.
getUserId
(),
req
.
getOrgId
(),
null
);
return
sysUser
;
}
public
SysUser
BindCabinet
(
PoliceListReq
req
,
String
orgId
)
{
String
accountSet
=
""
;
//判断是否有重复的账号
SysUser
one
=
sysUserService
.
getOne
(
new
LambdaQueryWrapper
<
SysUser
>()
.
eq
(
SysUser:
:
getAccount
,
req
.
getName
()));
if
(
ObjectUtil
.
isNotNull
(
one
)){
//警员账号如果已存在,则账号改为姓名+警号
accountSet
=
req
.
getName
()+
req
.
getPoliceCode
();
}
else
{
accountSet
=
req
.
getName
();
}
SysUser
sysUser
=
new
SysUser
();
BeanPlusUtil
.
copyProperties
(
req
,
sysUser
);
sysUser
.
setAccount
(
accountSet
);
sysUser
.
setNickName
(
req
.
getName
());
sysUser
.
setRealName
(
req
.
getName
());
SysUserCreateFactory
.
fillAddSysUser
(
sysUser
);
sysUser
.
setAvatar
(
FileConstant
.
DEFAULT_AVATAR_FILE_ID
);
sysUser
.
setDelFlag
(
LogicDelEnum
.
N
.
getCode
());
sysUser
.
setCreateTime
(
DateTime
.
now
());
sysUser
.
setUpdateTime
(
DateTime
.
now
());
sysUserService
.
save
(
sysUser
);
sysUserOrgService
.
add
(
sysUser
.
getUserId
(),
Long
.
valueOf
(
orgId
),
null
);
return
sysUser
;
}
/**
* 警员绑定账号
*
* @param
* @return
*/
public
SysUser
add
(
UpdatePolicemanReq
req
)
{
//判断是否有重复的账号
SysUser
one
=
sysUserService
.
getOne
(
new
LambdaQueryWrapper
<
SysUser
>()
...
...
@@ -401,13 +538,188 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
}).
collect
(
Collectors
.
toList
());
sysUserRoleService
.
saveBatch
(
collect
);
}
PubOrg
orgInfos
=
pubOrgService
.
getOne
(
new
LambdaQueryWrapper
<
PubOrg
>().
eq
(
PubOrg:
:
getOrgId
,
req
.
getOrgId
()));
orgInfos
.
setPoliceUpdateTime
(
DateTime
.
now
());
orgInfos
.
setPoliceUpdateService
(
"平台"
);
pubOrgService
.
updateById
(
orgInfos
);
List
<
Cabinet
>
cabinets
=
cabinetService
.
list
(
new
LambdaQueryWrapper
<
Cabinet
>().
eq
(
Cabinet:
:
getOrgIdInt
,
req
.
getCabinetOrgId
()));
//拿到组织机构下所有的警柜用于消息推送
if
(
cabinets
.
size
()>
0
)
{
cabinets
.
forEach
(
t
->
MQ
.
SendMsg
(
"cabinetMsg"
,
t
.
getCabinetNum
(),
"policeChange"
));
}
//警员添加成功之后,往消息队列推送人员更新的消息
MQ
.
SendMsg
(
"warehouseMsg"
,
req
.
getOrgId
().
toString
(),
"policeChange"
);
//推送至仓库主机
return
updateById
(
one
);
}
/**
* 修改警员信息
*
* @param req
* @return
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
UpdatePoliceFromCab
(
CabinetPolicemanReq
req
)
{
//判断警员是否存在
Policeman
policeInfo
=
PoliceExist
(
req
.
getPoliceId
());
IStoredEncryptApi
storedEncryptApi
=
(
IStoredEncryptApi
)
SpringUtil
.
getBean
(
IStoredEncryptApi
.
class
);
//查询传入的组织机构id是否存在
PubOrg
pubOrg
=
pubOrgService
.
PubOrgExist
(
req
.
getOrgId
());
//判断传入的修改的警员编号与本身编号一致,如果一致则无所谓,如果不一致则需要判断修改的警员编号是否已经存在
BeanPlusUtil
.
copyProperties
(
req
,
policeInfo
);
if
(!
req
.
getPoliceCode
().
equals
(
policeInfo
.
getPoliceCode
()))
{
//这里需要判断警号和姓名是否都存在
Policeman
exist
=
this
.
getOne
(
new
LambdaQueryWrapper
<
Policeman
>()
.
eq
(
Policeman:
:
getName
,
req
.
getName
())
.
and
(
wrapper
->
wrapper
.
eq
(
Policeman:
:
getPoliceCode
,
req
.
getPoliceCode
()))
);
if
(
ObjectUtil
.
isNotNull
(
exist
))
{
throw
new
ServiceException
(
PolicemanExceptionEnum
.
POLICECODE_IS_EXISTS
);
}
}
policeInfo
.
setUpdateTime
(
DateTimeUtil
.
getCurrentDateTime
());
PubOrg
orgInfo
=
pubOrgService
.
getOne
(
new
LambdaQueryWrapper
<
PubOrg
>().
eq
(
PubOrg:
:
getOrgId
,
req
.
getOrgId
()));
orgInfo
.
setPoliceUpdateTime
(
DateTime
.
now
());
orgInfo
.
setPoliceUpdateService
(
"平台"
);
pubOrgService
.
updateById
(
orgInfo
);
PubOrg
orgInfos
=
pubOrgService
.
getOne
(
new
LambdaQueryWrapper
<
PubOrg
>().
eq
(
PubOrg:
:
getOrgId
,
req
.
getOrgId
()));
orgInfos
.
setPoliceUpdateTime
(
DateTime
.
now
());
Cabinet
cabinetOrg
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>().
eq
(
Cabinet:
:
getCabinetNum
,
req
.
getSerialNum
()));
orgInfos
.
setPoliceUpdateService
(
cabinetOrg
.
getName
()+
"-"
+
cabinetOrg
.
getCabinetNum
());
pubOrgService
.
updateById
(
orgInfos
);
//人员信息修改之后推送至本地主机和单警柜
List
<
Cabinet
>
list
=
cabinetService
.
list
(
new
LambdaQueryWrapper
<
Cabinet
>().
eq
(
Cabinet:
:
getOrgIdInt
,
pubOrg
.
getOrgId
()));
List
<
String
>
cabinetIdList
=
list
.
stream
().
map
(
cabinet
->
cabinet
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
Cabinet
>
cabinets
=
cabinetService
.
list
(
new
LambdaQueryWrapper
<
Cabinet
>().
eq
(
Cabinet:
:
getOrgIdInt
,
req
.
getCabinetOrgId
()));
//拿到组织机构下所有的警柜用于消息推送
if
(
cabinets
.
size
()>
0
)
{
cabinets
.
forEach
(
t
->
MQ
.
SendMsg
(
"cabinetMsg"
,
t
.
getCabinetNum
(),
"policeChange"
));
}
return
updateById
(
one
);
MQ
.
SendMsg
(
"warehouseMsg"
,
req
.
getOrgId
().
toString
(),
"policeChange"
);
//推送至仓库主机
return
updateById
(
policeInfo
);
}
/**
* 修改警员信息
*
* @param req
* @return
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
UploadPolicemanList
(
CabinetUploadReq
req
)
{
List
<
CabinetDataList
>
dataList
=
req
.
getDataList
();
for
(
CabinetDataList
orgList
:
dataList
)
{
// 查询数据库中的警员列表
List
<
Policeman
>
policeList
=
this
.
list
(
new
LambdaQueryWrapper
<
Policeman
>()
.
eq
(
Policeman:
:
getOrgId
,
orgList
.
getOrgId
()));
// 获取上报的警员列表
List
<
PoliceListReq
>
policeReqList
=
orgList
.
getPoliceList
();
// 比较并处理新增、删除和修改的数据
List
<
Policeman
>
toAdd
=
new
ArrayList
<>();
List
<
Policeman
>
toDelete
=
new
ArrayList
<>();
List
<
Policeman
>
toUpdate
=
new
ArrayList
<>();
// 处理新增和修改
for
(
PoliceListReq
reqPolice
:
policeReqList
)
{
Policeman
dbPolice
=
findPoliceById
(
policeList
,
reqPolice
.
getPoliceID
());
if
(
dbPolice
==
null
)
{
// 新增数据
Policeman
newPolice
=
convertToPoliceman
(
reqPolice
,
orgList
.
getOrgId
());
toAdd
.
add
(
newPolice
);
}
else
{
// 修改数据
Policeman
updatedPolice
=
updatePoliceman
(
dbPolice
,
reqPolice
);
toUpdate
.
add
(
updatedPolice
);
}
}
// 处理删除
for
(
Policeman
dbPolice
:
policeList
)
{
PoliceListReq
matchingReqPolice
=
findPoliceReqById
(
policeReqList
,
dbPolice
.
getId
());
if
(
matchingReqPolice
==
null
)
{
dbPolice
.
setState
(
0
);
// 数据库中存在但上报数据中不存在,需要删除
toDelete
.
add
(
dbPolice
);
}
}
// 执行新增、删除和修改操作
if
(!
toAdd
.
isEmpty
())
{
this
.
saveBatch
(
toAdd
);
}
if
(!
toUpdate
.
isEmpty
())
{
this
.
updateBatchById
(
toUpdate
);
}
if
(!
toDelete
.
isEmpty
())
{
this
.
updateBatchById
(
toUpdate
);
}
}
//人员信息修改之后推送至本地主机和单警柜
List
<
Cabinet
>
cabinets
=
cabinetService
.
list
(
new
LambdaQueryWrapper
<
Cabinet
>().
eq
(
Cabinet:
:
getOrgIdInt
,
req
.
getCabinetOrgId
()));
//拿到组织机构下所有的警柜用于消息推送
if
(
cabinets
.
size
()>
0
)
{
cabinets
.
forEach
(
t
->
MQ
.
SendMsg
(
"cabinetMsg"
,
t
.
getCabinetNum
(),
"policeChange"
));
}
req
.
getDataList
().
forEach
(
t
->
MQ
.
SendMsg
(
"warehouseMsg"
,
t
.
getOrgId
(),
"policeChange"
));
//推送至仓库主机
return
true
;
}
// 辅助方法:根据警员ID在列表中查找警员
private
Policeman
findPoliceById
(
List
<
Policeman
>
policeList
,
String
policeId
)
{
return
policeList
.
stream
().
filter
(
p
->
Objects
.
equals
(
p
.
getId
(),
policeId
)).
findFirst
().
orElse
(
null
);
}
// 辅助方法:根据警员ID在上报数据列表中查找警员
private
PoliceListReq
findPoliceReqById
(
List
<
PoliceListReq
>
policeReqList
,
String
policeId
)
{
return
policeReqList
.
stream
().
filter
(
p
->
Objects
.
equals
(
p
.
getPoliceID
(),
policeId
)).
findFirst
().
orElse
(
null
);
}
// 辅助方法:将 PoliceListReq 转换为 Policeman 对象
private
Policeman
convertToPoliceman
(
PoliceListReq
reqPolice
,
String
orgID
)
{
//警柜添加的人员统一视为用户
String
UserRoleId
=
"1716370847267106817"
;
List
<
Long
>
roleList
=
new
ArrayList
<>();
roleList
.
add
(
Long
.
valueOf
(
UserRoleId
));
reqPolice
.
setRolesList
(
roleList
);
//绑定账号
SysUser
sysUser
=
BindCabinet
(
reqPolice
,
orgID
);
//判断是否添加角色,进行绑定
List
<
SysUserRole
>
sysUserRoleList
=
new
ArrayList
<>()
;
if
(
reqPolice
.
getRolesList
().
size
()>
0
){
for
(
Long
roleId:
reqPolice
.
getRolesList
())
{
SysUserRole
sysUserRole
=
new
SysUserRole
();
sysUserRole
.
setRoleId
(
roleId
);
sysUserRole
.
setUserId
(
sysUser
.
getUserId
());
sysUserRole
.
setCreateTime
(
DateTimeUtil
.
getCurrentDateTime
());
// sysUserRole.setCreateUser("cabinet");
sysUserRoleList
.
add
(
sysUserRole
);
}
}
sysUserRoleService
.
saveBatch
(
sysUserRoleList
);
Policeman
policeman
=
new
Policeman
();
BeanPlusUtil
.
copyProperties
(
reqPolice
,
policeman
);
policeman
.
setPassword
(
sysUser
.
getPassword
());
policeman
.
setState
(
1
);
policeman
.
setUserId
(
sysUser
.
getUserId
());
policeman
.
setCreateTime
(
DateTimeUtil
.
getCurrentDateTime
());
policeman
.
setUpdateTime
(
DateTimeUtil
.
getCurrentDateTime
());
save
(
policeman
);
return
policeman
;
}
// 辅助方法:更新 Policeman 对象的属性
private
Policeman
updatePoliceman
(
Policeman
dbPolice
,
PoliceListReq
reqPolice
)
{
//判断警员是否存在
//判断传入的修改的警员编号与本身编号一致,如果一致则无所谓,如果不一致则需要判断修改的警员编号是否已经存在
BeanPlusUtil
.
copyProperties
(
reqPolice
,
dbPolice
);
dbPolice
.
setUpdateTime
(
DateTimeUtil
.
getCurrentDateTime
());
return
dbPolice
;
}
/**
* 修改用户状态
...
...
@@ -454,41 +766,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
return
allPoliceman
;
}
/**
* 通过条件查询警员列表(list)
*
* @param
*/
@Override
// public List<PolicemanDto> GetAllPolicemanList(PolicemanReq req) {
// //查询传入的组织机构id是否存在
// PubOrg pubOrg = pubOrgService.PubOrgExist(req.getOrgId());
// //查询出组织机构下的所有警员信息(如果是查看启用的那么state为1)
// List<Policeman> list = list(new LambdaQueryWrapper<Policeman>()
// .eq(ObjectUtil.isNotEmpty(req.getOrgId()), Policeman::getOrgId, req.getOrgId())
// .like(ObjectUtil.isNotEmpty(req.getName()),Policeman::getName,req.getName())
// .like(ObjectUtil.isNotEmpty(req.getPoliceCode()),Policeman::getPoliceCode,req.getPoliceCode())
// .eq(ObjectUtil.isNotEmpty( req.getState()),Policeman::getState, req.getState()));
// List<PolicemanDto> policeList = new ArrayList<>();
// //查询出警员信息下的指纹列表信息
// for (Policeman p : list) {
// PolicemanDto policemanDto = new PolicemanDto();
// BeanPlusUtil.copyProperties(p, policemanDto);
// List<PoliceFinger> list1 = policeFingerService.list(new LambdaQueryWrapper<PoliceFinger>()
// .eq(ObjectUtil.isNotNull(p.getId()), PoliceFinger::getPoliceId, p.getId()));
// List<PoliceFingerDto> policeFingerDtoList = new ArrayList<>();
// for (PoliceFinger policeFinger : list1) {
// PoliceFingerDto policeFingerDto = new PoliceFingerDto();
// BeanPlusUtil.copyProperties(policeFinger, policeFingerDto);
// policeFingerDtoList.add(policeFingerDto);
// }
// policemanDto.setFingersList(policeFingerDtoList);
// policemanDto.setOrgName(pubOrg.getOrgName());
// policeList.add(policemanDto);
//
// }
// return policeList;
// }
public
List
<
PolicemanDto
>
GetAllPolicemanList
(
PolicemanReq
req
)
{
if
(
ObjectUtil
.
isNotNull
(
req
.
getColumn
())
&&
!
req
.
getColumn
().
trim
().
isEmpty
()
&&
(
req
.
getOrder
().
equalsIgnoreCase
(
"asc"
)||
req
.
getOrder
().
equalsIgnoreCase
(
"desc"
))
&&
...
...
@@ -511,6 +789,79 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
return
policemanDtos
;
}
private
final
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
5
);
// 适当设置线程池大小
public
List
<
CabinetPoliceDto
>
GetListByOrgAsync
(
PolicemanReq
req
)
{
List
<
CompletableFuture
<
CabinetPoliceDto
>>
futures
=
new
ArrayList
<>();
for
(
String
org
:
req
.
getOrgList
())
{
CompletableFuture
<
CabinetPoliceDto
>
future
=
CompletableFuture
.
supplyAsync
(()
->
{
return
processOrg
(
org
);
},
executorService
);
futures
.
add
(
future
);
}
CompletableFuture
<
Void
>
allOf
=
CompletableFuture
.
allOf
(
futures
.
toArray
(
new
CompletableFuture
[
0
]));
try
{
// 等待所有异步任务完成
allOf
.
get
(
30
,
TimeUnit
.
SECONDS
);
}
catch
(
InterruptedException
|
ExecutionException
|
java
.
util
.
concurrent
.
TimeoutException
e
)
{
e
.
printStackTrace
();
// 处理异常,具体根据业务需要进行调整
}
List
<
CabinetPoliceDto
>
result
=
new
ArrayList
<>();
for
(
CompletableFuture
<
CabinetPoliceDto
>
future
:
futures
)
{
try
{
result
.
add
(
future
.
get
());
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
e
.
printStackTrace
();
// 处理异常,具体根据业务需要进行调整
}
}
return
result
;
}
private
CabinetPoliceDto
processOrg
(
String
org
)
{
CabinetPoliceDto
cpDto
=
new
CabinetPoliceDto
();
// 获取组织机构信息
PubOrg
orgInfo
=
pubOrgService
.
getOne
(
new
LambdaQueryWrapper
<
PubOrg
>().
eq
(
PubOrg:
:
getOrgId
,
org
));
cpDto
.
setOrgId
(
org
);
cpDto
.
setLastAction
(
orgInfo
.
getPoliceUpdateService
());
cpDto
.
setActionUpdateTime
(
String
.
valueOf
(
orgInfo
.
getPoliceUpdateTime
()));
cpDto
.
setOrgName
(
orgInfo
.
getOrgName
());
// 获取组织机构下的警员列表
List
<
Policeman
>
policeList
=
this
.
list
(
new
LambdaQueryWrapper
<
Policeman
>().
eq
(
Policeman:
:
getOrgId
,
org
));
// 转换警员信息为 PoliceDetailDto
List
<
PoliceDetailDto
>
policeDtoList
=
new
ArrayList
<>();
for
(
Policeman
police
:
policeList
)
{
PoliceDetailDto
pdDto
=
new
PoliceDetailDto
();
BeanPlusUtil
.
copyProperties
(
police
,
pdDto
);
//将箱门信息展示:
List
<
Cabinet
>
cabinetInfo
=
cabinetMapper
.
getAllCabinetsWithSingleCabinet
(
org
,
police
.
getId
());
List
<
String
>
boxList
=
new
ArrayList
<>();
if
(
cabinetInfo
.
size
()>
0
){
for
(
Cabinet
cabinet:
cabinetInfo
)
{
if
(
cabinet
.
getContainType
().
equals
(
"1"
)){
boxList
.
add
(
0
,
cabinet
.
getBoxId
());
}
else
{
boxList
.
add
(
cabinet
.
getBoxId
());
}
}
pdDto
.
setBoxList
(
boxList
);
}
policeDtoList
.
add
(
pdDto
);
}
cpDto
.
setPoliceList
(
policeDtoList
);
return
cpDto
;
}
//通过组织机构id查询警员列表(page)
@Override
public
PageResult
<
PolicemanDto
>
GetAllPolicemanPage
(
PolicemanReq
req
)
{
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/utils/RabbitMQSendMsg.java
View file @
c1549f9e
...
...
@@ -24,6 +24,12 @@ public class RabbitMQSendMsg {
rabbitAdmin
.
declareExchange
(
exchange
);
rabbitAdmin
.
declareBinding
(
BindingBuilder
.
bind
(
queue
).
to
(
exchange
).
with
(
name
).
noargs
());
String
jsonString
=
JSON
.
toJSONString
(
msg
);
// // 创建 MessageProperties 对象,并设置 TTL
// MessageProperties messageProperties = new MessageProperties();
// messageProperties.setExpiration(String.valueOf(ttlMillis));
//
// // 发送带有 TTL 的消息
// rabbitTemplate.send(exchangeName, name, new Message(jsonString.getBytes(), messageProperties));
rabbitTemplate
.
convertAndSend
(
exchangeName
,
name
,
jsonString
);
}
...
...
jyzb-biz/src/main/java/com/junmp/jyzb/websocket/CustomScreenWebSocketServer.java
0 → 100644
View file @
c1549f9e
package
com
.
junmp
.
jyzb
.
websocket
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
com.alibaba.fastjson2.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.junmp.jyzb.api.bean.req.wsReq.OnOpenReq
;
import
com.junmp.jyzb.cache.OnlineRedisCache
;
import
com.junmp.jyzb.cache.TemperatureRedisCache
;
import
com.junmp.jyzb.entity.Cabinet
;
import
com.junmp.jyzb.entity.Reassignment
;
import
com.junmp.jyzb.entity.Temp.OnlineState
;
import
com.junmp.jyzb.service.CabinetService
;
import
com.junmp.v2.ws.api.enums.ClientMsgType
;
import
com.junmp.v2.ws.api.enums.ServerMsgType
;
import
com.junmp.v2.ws.api.enums.SysMsgTypeEnum
;
import
com.junmp.v2.ws.api.message.WsCallbackApi
;
import
com.junmp.v2.ws.api.session.bean.WsSession
;
import
com.junmp.v2.ws.bean.WsMsgDto
;
import
com.junmp.v2.ws.channel.WsSessionContainer
;
import
com.junmp.v2.ws.message.WsMessageHandle
;
import
com.junmp.v2.ws.server.ScreenWebSocketServer
;
import
com.junmp.v2.ws.session.WsSessionHandle
;
import
io.jsonwebtoken.JwtException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.websocket.*
;
import
javax.websocket.server.PathParam
;
import
javax.websocket.server.ServerEndpoint
;
import
java.io.IOException
;
import
java.time.Instant
;
//@Component
//@ServerEndpoint("/notice1/{data}")
//public class CustomScreenWebSocketServer extends ScreenWebSocketServer {
// @Override
//
// public void onOpen(Session session, @PathParam("data") String data) {
// String aa=data;
// // Your custom logic here
// super.onOpen(session, data); // Call the original method if needed
// }
//}
@Component
@ServerEndpoint
(
"/notice1/{data}"
)
public
class
CustomScreenWebSocketServer
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
com
.
junmp
.
v2
.
ws
.
server
.
ScreenWebSocketServer
.
class
);
@Resource
public
CabinetService
cabinetService
;
@Resource
private
OnlineRedisCache
onlineRedisCache
;
public
CustomScreenWebSocketServer
()
{
}
@OnOpen
public
void
onOpen
(
Session
session
,
@PathParam
(
"data"
)
String
data
)
{
String
userId
=
null
;
try
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
OnOpenReq
onOpenObject
=
objectMapper
.
readValue
(
data
,
OnOpenReq
.
class
);
String
type
=
onOpenObject
.
getType
();
String
typeId
=
onOpenObject
.
getTypeId
();
// 获取当前时间的时间戳
Instant
now
=
Instant
.
now
();
// 转换为long类型
long
timestamp
=
now
.
toEpochMilli
();
if
(
type
.
equals
(
"cabinet"
))
//警柜已连接
{
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
typeId
));
cabinet
.
setOnlineState
(
1
);
cabinet
.
setUpdateTime
(
DateTime
.
now
());
// cabinetService.updateById(cabinet);
// //将数据放入redis
// onlineRedisCache.addSessionValue(session.getId(),type,typeId,timestamp);
}
else
if
(
type
.
equals
(
"warehouse"
))
{
//仓库主机已连接
}
}
catch
(
JwtException
|
JsonProcessingException
var15
)
{
log
.
error
(
"建立连接异常>>"
+
var15
.
getMessage
());
try
{
session
.
close
();
log
.
warn
(
"因连接失败,会话自动关闭"
);
}
catch
(
IOException
var14
)
{
var14
.
printStackTrace
();
log
.
error
(
"会话关闭异常>>"
+
var14
.
getMessage
());
}
}
WsSessionContainer
wsContainer
=
new
WsSessionContainer
(
session
);
WsSession
<
WsSessionContainer
>
socketSession
=
new
WsSession
();
WsMsgDto
replyMsg
=
new
WsMsgDto
();
boolean
var13
=
false
;
try
{
var13
=
true
;
replyMsg
.
setServerMsgType
(
ServerMsgType
.
REPLY_MSG_TYPE
.
getCode
());
// replyMsg.setToUserId(userId);
replyMsg
.
setData
(
session
.
getId
());
socketSession
.
setSessionId
(
session
.
getId
());
socketSession
.
setUserId
(
userId
);
socketSession
.
setWsApi
(
wsContainer
);
socketSession
.
setToken
(
data
);
// socketSession.setData();
socketSession
.
setConnectionTime
(
System
.
currentTimeMillis
());
WsSessionHandle
.
addWsSession
(
socketSession
);
var13
=
false
;
}
finally
{
if
(
var13
)
{
wsContainer
.
writeAndFlush
(
replyMsg
);
WsCallbackApi
wsCallbackApi
=
WsMessageHandle
.
getWsCallback
(
SysMsgTypeEnum
.
LISTENER_ON_OPEN
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
wsCallbackApi
))
{
wsCallbackApi
.
callback
(
SysMsgTypeEnum
.
LISTENER_ON_OPEN
.
getCode
(),
(
Object
)
null
,
socketSession
);
}
log
.
info
(
"已建立连接"
);
}
}
wsContainer
.
writeAndFlush
(
replyMsg
);
WsCallbackApi
wsCallbackApi
=
WsMessageHandle
.
getWsCallback
(
SysMsgTypeEnum
.
LISTENER_ON_OPEN
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
wsCallbackApi
))
{
wsCallbackApi
.
callback
(
SysMsgTypeEnum
.
LISTENER_ON_OPEN
.
getCode
(),
(
Object
)
null
,
socketSession
);
}
log
.
info
(
"已建立连接"
);
}
@OnMessage
public
void
onMessage
(
String
message
,
Session
channel
)
{
WsMsgDto
wsMsgDto
=
(
WsMsgDto
)
JSON
.
parseObject
(
message
,
WsMsgDto
.
class
);
WsSession
<
WsSessionContainer
>
wsSession
=
WsSessionHandle
.
getSessionBySessionId
(
channel
.
getId
());
if
(
ObjectUtil
.
isNotEmpty
(
wsSession
)
&&
ClientMsgType
.
USER_HEART
.
getCode
().
equals
(
wsMsgDto
.
getClientMsgType
()))
{
log
.
info
(
StrUtil
.
format
(
"来自与客户端[{}]的心跳消息。"
,
new
Object
[]{
wsMsgDto
.
getFromUserId
()}));
if
(
ObjectUtil
.
isNotEmpty
(
wsSession
))
{
wsSession
.
setLastActiveTime
(
System
.
currentTimeMillis
());
}
}
else
if
(!
ObjectUtil
.
isEmpty
(
wsMsgDto
.
getFromUserId
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
wsSession
))
{
wsSession
.
setLastActiveTime
(
System
.
currentTimeMillis
());
WsCallbackApi
callbackApi
;
if
(
ClientMsgType
.
OPEN_AI_TYPE
.
getCode
().
equals
(
wsMsgDto
.
getClientMsgType
()))
{
log
.
info
(
StrUtil
.
format
(
"来自与客户端[{}]调用OpenAi的消息。"
,
new
Object
[]{
wsMsgDto
.
getFromUserId
()}));
callbackApi
=
(
WsCallbackApi
)
SpringUtil
.
getBean
(
WsCallbackApi
.
class
);
if
(
ObjectUtil
.
isNull
(
callbackApi
))
{
log
.
warn
(
"回调WsCallbackApi未注册."
);
}
else
{
callbackApi
.
callback
(
wsMsgDto
.
getClientMsgType
(),
wsMsgDto
.
getData
(),
wsSession
);
}
}
else
{
callbackApi
=
WsMessageHandle
.
getWsCallback
(
wsMsgDto
.
getClientMsgType
());
if
(
ObjectUtil
.
isNotEmpty
(
callbackApi
))
{
callbackApi
.
callback
(
wsMsgDto
.
getClientMsgType
(),
wsMsgDto
,
wsSession
);
}
else
{
log
.
warn
(
"未知的消息类型"
);
channel
.
getAsyncRemote
().
sendText
(
"{\"serverMsgType\":\"未知的消息类型\"}"
);
}
}
}
}
}
@OnClose
public
void
onClose
(
Session
session
)
{
try
{
WsSession
<
WsSessionContainer
>
wsSession
=
WsSessionHandle
.
getSessionBySessionId
(
session
.
getId
());
WsCallbackApi
wsCallbackApi
=
WsMessageHandle
.
getWsCallback
(
SysMsgTypeEnum
.
LISTENER_ON_CLOSE
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
wsSession
)
&&
ObjectUtil
.
isNotEmpty
(
wsCallbackApi
))
{
OnlineState
os
=
onlineRedisCache
.
getDataValue
(
wsSession
.
getSessionId
());
String
type
=
os
.
getType
();
String
typeId
=
os
.
getTypeId
();
if
(
type
.
equals
(
"cabinet"
))
//警柜断开连接
{
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
typeId
));
cabinet
.
setOnlineState
(
0
);
cabinet
.
setUpdateTime
(
DateTime
.
now
());
cabinetService
.
updateById
(
cabinet
);
onlineRedisCache
.
remove
(
wsSession
.
getSessionId
());
}
else
if
(
type
.
equals
(
"warehouse"
))
{
//仓库主机已连接
}
wsCallbackApi
.
callback
(
SysMsgTypeEnum
.
LISTENER_ON_CLOSE
.
getCode
(),
(
Object
)
null
,
wsSession
);
}
}
finally
{
WsSessionHandle
.
delById
(
session
.
getId
());
log
.
warn
(
"会话已关闭"
);
}
}
@OnError
public
void
onError
(
Session
session
,
Throwable
error
)
{
WsSession
<
WsSessionContainer
>
wsSession
=
WsSessionHandle
.
getSessionBySessionId
(
session
.
getId
());
WsCallbackApi
wsCallbackApi
=
WsMessageHandle
.
getWsCallback
(
SysMsgTypeEnum
.
LISTENER_ON_ERROR
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
wsCallbackApi
))
{
wsCallbackApi
.
callback
(
SysMsgTypeEnum
.
LISTENER_ON_ERROR
.
getCode
(),
(
Object
)
null
,
wsSession
);
}
}
}
jyzb-process/src/main/java/com/junmp/junmpProcess/config/ActivitiConfig.java
View file @
c1549f9e
...
...
@@ -43,6 +43,7 @@ public class ActivitiConfig {
config
.
setDataSource
(
dataSource
);
config
.
setTransactionManager
(
transactionManager
);
config
.
setDisableIdmEngine
(
true
);
config
.
setAsyncExecutorNumberOfRetries
(
0
);
config
.
setDatabaseType
(
ProcessEngineConfigurationImpl
.
DATABASE_TYPE_MYSQL
);
config
.
setDatabaseSchemaUpdate
(
ProcessEngineConfiguration
.
DB_SCHEMA_UPDATE_FALSE
);
config
.
setDelegateExpressionFieldInjectionMode
(
DelegateExpressionFieldInjectionMode
.
MIXED
);
...
...
pom.xml
View file @
c1549f9e
...
...
@@ -290,6 +290,22 @@
<version>
${junmp.v2.version}
</version>
</dependency>
<!--ws模块-->
<dependency>
<groupId>
com.junmp.v2
</groupId>
<artifactId>
ws-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
com.junmp.v2
</groupId>
<artifactId>
ws-sdk
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
com.junmp.v2
</groupId>
<artifactId>
ws-boot-starter
</artifactId>
<version>
${project.version}
</version>
</dependency>
<!--消息推送-->
<dependency>
<groupId>
com.junmp.v2
</groupId>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论