Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bb956ce9
authored
Oct 25, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
2 parents
66af4c89
cffcb177
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
180 additions
and
22 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/MsgController.java
project-order/src/main/java/com/dituhui/pea/order/dao/MsgDao.java
project-order/src/main/java/com/dituhui/pea/order/dao/MsgReceiverDao.java
project-order/src/main/java/com/dituhui/pea/order/dto/MsgDTO.java
project-order/src/main/java/com/dituhui/pea/order/dto/MsgResp.java
project-order/src/main/java/com/dituhui/pea/order/entity/MsgEntity.java
project-order/src/main/java/com/dituhui/pea/order/entity/MsgReceiverEntity.java
project-order/src/main/java/com/dituhui/pea/order/entity/OrderInfoEntity.java
project-order/src/main/java/com/dituhui/pea/order/service/MsgService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/MsgServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/MsgController.java
View file @
bb956ce
package
com
.
dituhui
.
pea
.
order
.
controller
;
package
com
.
dituhui
.
pea
.
order
.
controller
;
import
cn.hutool.core.util.StrUtil
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.MsgDTO
;
import
com.dituhui.pea.order.dto.MsgDTO
;
...
@@ -8,7 +9,7 @@ import com.dituhui.pea.order.dto.MsgResp;
...
@@ -8,7 +9,7 @@ import com.dituhui.pea.order.dto.MsgResp;
import
com.dituhui.pea.order.service.MsgService
;
import
com.dituhui.pea.order.service.MsgService
;
import
com.dituhui.pea.order.utils.AssertUtil
;
import
com.dituhui.pea.order.utils.AssertUtil
;
import
com.dituhui.pea.order.utils.CommonUtil
;
import
com.dituhui.pea.order.utils.CommonUtil
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
...
@@ -21,11 +22,11 @@ import java.util.Objects;
...
@@ -21,11 +22,11 @@ import java.util.Objects;
* @date 2023/10/24
* @date 2023/10/24
*/
*/
@RestController
@RestController
@RequiredArgsConstructor
@RequestMapping
(
"/pea-order"
)
@RequestMapping
(
"/pea-order"
)
public
class
MsgController
{
public
class
MsgController
{
private
final
MsgService
msgService
;
@Autowired
private
MsgService
msgService
;
/**
/**
* 消息列表
* 消息列表
...
@@ -58,15 +59,49 @@ public class MsgController {
...
@@ -58,15 +59,49 @@ public class MsgController {
* 删除消息
* 删除消息
*
*
* @param userId 用户标识
* @param userId 用户标识
* @param d
eleteD
to
* @param dto
* @return {@link Result }<{@link Boolean }>
* @return {@link Result }<{@link Boolean }>
* @author RenPing
* @author RenPing
* @date 2023/10/24
* @date 2023/10/24
*/
*/
@
RequestMapping
(
value
=
"/msg/delete"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/msg/delete"
)
public
Result
<
Boolean
>
delete
(
@RequestHeader
(
name
=
"userId"
,
required
=
true
)
String
userId
,
@RequestBody
@Valid
MsgDTO
.
DeleteDto
d
eleteD
to
)
{
public
Result
<
Boolean
>
delete
(
@RequestHeader
(
name
=
"userId"
,
required
=
true
)
String
userId
,
@RequestBody
@Valid
MsgDTO
.
DeleteDto
dto
)
{
AssertUtil
.
isNotEmpty
(
userId
,
"用户ID不能为空"
);
AssertUtil
.
isNotEmpty
(
userId
,
"用户ID不能为空"
);
msgService
.
delete
(
deleteDto
.
getId
(),
userId
);
msgService
.
delete
(
dto
.
getId
(),
userId
);
return
Result
.
success
(
true
);
}
/**
* 设置消息已读
*
* @param userId 用户标识
* @param dto
* @return {@link Result }<{@link Boolean }>
* @author RenPing
* @date 2023/10/24
*/
@PostMapping
(
"/msg/read"
)
public
Result
<
Boolean
>
read
(
@RequestHeader
(
name
=
"userId"
,
required
=
true
)
String
userId
,
@RequestBody
@Valid
MsgDTO
.
ReadDto
dto
)
{
AssertUtil
.
isNotEmpty
(
userId
,
"用户ID不能为空"
);
msgService
.
readMsg
(
dto
.
getIds
(),
userId
);
return
Result
.
success
(
true
);
}
/**
* 新增消息
*
* @param dto 参数
* @return {@link Result }<{@link Boolean }>
* @author RenPing
* @date 2023/10/25
*/
@PostMapping
(
"/msg/add"
)
public
Result
<
Boolean
>
add
(
@RequestBody
@Valid
MsgDTO
.
addDto
dto
)
{
CommonUtil
.
setNullValue
(
dto
);
AssertUtil
.
checkArgument
(
StrUtil
.
isNotEmpty
(
dto
.
getClusterId
())
||
StrUtil
.
isNotEmpty
(
dto
.
getBranchId
())
||
StrUtil
.
isNotEmpty
(
dto
.
getGroupId
()),
"大区Id、分部Id、分组Id不能同时为空"
);
msgService
.
add
(
dto
);
return
Result
.
success
(
true
);
return
Result
.
success
(
true
);
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/MsgDao.java
View file @
bb956ce
...
@@ -15,7 +15,7 @@ import java.util.List;
...
@@ -15,7 +15,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
public
interface
MsgDao
extends
JpaRepository
<
MsgEntity
,
Long
>
{
public
interface
MsgDao
extends
JpaRepository
<
MsgEntity
,
Integer
>
{
@Query
(
value
=
"select t.cluster_id,t.branch_id,t.group_id"
+
@Query
(
value
=
"select t.cluster_id,t.branch_id,t.group_id"
+
" from ("
+
" from ("
+
" select tt.cluster_id,tt.branch_id,tt.group_id,min(tt.create_time) create_time,min(r.is_read) is_read"
+
" select tt.cluster_id,tt.branch_id,tt.group_id,min(tt.create_time) create_time,min(r.is_read) is_read"
+
...
@@ -39,7 +39,8 @@ public interface MsgDao extends JpaRepository<MsgEntity, Long> {
...
@@ -39,7 +39,8 @@ public interface MsgDao extends JpaRepository<MsgEntity, Long> {
Page
<
Map
<
String
,
Objects
>>
getGroupList
(
@Param
(
"req"
)
MsgDTO
.
Request
req
,
Pageable
pageable
);
Page
<
Map
<
String
,
Objects
>>
getGroupList
(
@Param
(
"req"
)
MsgDTO
.
Request
req
,
Pageable
pageable
);
@Query
(
value
=
"select t.* from (select tt.*,r.is_read"
+
@Query
(
value
=
"select t.* from (select tt.*,r.is_read,"
+
" (select group_concat(u.nickname) from zzz_msg_receiver rr join sys_user u on u.id=rr.user_id where rr.msg_id=tt.id) receivers"
+
" from zzz_msg tt join zzz_msg_receiver r on r.msg_id=tt.id and r.user_id=:#{#req.userId}"
+
" from zzz_msg tt join zzz_msg_receiver r on r.msg_id=tt.id and r.user_id=:#{#req.userId}"
+
" where IF(:#{#msgGroupResp.clusterId} is not null, tt.cluster_id=:#{#msgGroupResp.clusterId}, tt.cluster_id is null)"
+
" where IF(:#{#msgGroupResp.clusterId} is not null, tt.cluster_id=:#{#msgGroupResp.clusterId}, tt.cluster_id is null)"
+
" and IF(:#{#msgGroupResp.branchId} is not null, tt.branch_id=:#{#msgGroupResp.branchId}, tt.branch_id is null)"
+
" and IF(:#{#msgGroupResp.branchId} is not null, tt.branch_id=:#{#msgGroupResp.branchId}, tt.branch_id is null)"
+
...
@@ -52,4 +53,28 @@ public interface MsgDao extends JpaRepository<MsgEntity, Long> {
...
@@ -52,4 +53,28 @@ public interface MsgDao extends JpaRepository<MsgEntity, Long> {
)
)
List
<
Map
<
String
,
Objects
>>
getList
(
@Param
(
"req"
)
MsgDTO
.
Request
req
List
<
Map
<
String
,
Objects
>>
getList
(
@Param
(
"req"
)
MsgDTO
.
Request
req
,
@Param
(
"msgGroupResp"
)
MsgGroupResp
msgGroupResp
,
Pageable
pageable
);
,
@Param
(
"msgGroupResp"
)
MsgGroupResp
msgGroupResp
,
Pageable
pageable
);
/**
* 根据小组或分部或大区获取角色为“分站派工”的用户
*
* @param clusterId 大区
* @param branchId 分部
* @param groupId 小组
* @return {@link List }<{@link String }>
* @author RenPing
* @date 2023/10/25
*/
@Query
(
value
=
"SELECT distinct u.id"
+
" from sys_user u"
+
" join sys_user_org uo on u.id=uo.user_id"
+
" join sys_user_role ur on ur.user_id=u.id"
+
" join sys_role r on r.id=ur.role_id and r.name='分站派工'"
+
" and IF(:groupId is not null, uo.org_id=:groupId and uo.org_level=2, 1=1)"
+
" and IF(:groupId is null and :branchId is not null, uo.org_id=:branchId and uo.org_level=1, 1=1)"
+
" and IF(:groupId is null and :branchId is null and :clusterId is not null, uo.org_id=:clusterId and uo.org_level=0, 1=1)"
,
nativeQuery
=
true
// 开启原生sql
)
List
<
String
>
getDispatchUserList
(
@Param
(
"clusterId"
)
String
clusterId
,
@Param
(
"branchId"
)
String
branchId
,
@Param
(
"groupId"
)
String
groupId
);
}
}
project-order/src/main/java/com/dituhui/pea/order/dao/MsgReceiverDao.java
View file @
bb956ce
...
@@ -4,10 +4,12 @@ import com.dituhui.pea.order.entity.MsgReceiverEntity;
...
@@ -4,10 +4,12 @@ import com.dituhui.pea.order.entity.MsgReceiverEntity;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
public
interface
MsgReceiverDao
extends
JpaRepository
<
MsgReceiverEntity
,
Long
>
{
import
java.util.List
;
public
interface
MsgReceiverDao
extends
JpaRepository
<
MsgReceiverEntity
,
Integer
>
{
@Modifying
@Modifying
@Query
(
"delete from MsgReceiverEntity a where a.msgId=?1 and a.userId=?2"
)
@Query
(
value
=
"update zzz_msg_receiver set is_read=1 where msg_id in (:msgIds) and user_id=:userId"
,
nativeQuery
=
true
)
void
delete
(
Integer
msgId
,
String
userId
);
void
read
(
@Param
(
"msgIds"
)
List
<
Integer
>
msgIds
,
@Param
(
"userId"
)
String
userId
);
}
}
project-order/src/main/java/com/dituhui/pea/order/dto/MsgDTO.java
View file @
bb956ce
...
@@ -3,10 +3,14 @@ package com.dituhui.pea.order.dto;
...
@@ -3,10 +3,14 @@ package com.dituhui.pea.order.dto;
import
com.dituhui.pea.pojo.PageRequest
;
import
com.dituhui.pea.pojo.PageRequest
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.validation.constraints.Max
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
static
com
.
dituhui
.
pea
.
order
.
config
.
OrderConfig
.
DEFAULT_PAGE_SIZE
;
import
static
com
.
dituhui
.
pea
.
order
.
config
.
OrderConfig
.
DEFAULT_PAGE_SIZE
;
...
@@ -65,12 +69,22 @@ public class MsgDTO {
...
@@ -65,12 +69,22 @@ public class MsgDTO {
private
Integer
id
;
private
Integer
id
;
}
}
@lombok
.
Data
public
static
class
ReadDto
{
/**
* 消息Id集合
*/
@NotEmpty
(
message
=
"消息Id集合不能为空"
)
private
List
<
Integer
>
ids
;
}
@lombok
.
Data
@lombok
.
Data
public
static
class
addDto
{
public
static
class
addDto
{
/**
/**
* 大区ID
* 大区ID
(大区Id、分部Id、分组Id只需传一个)
*/
*/
private
String
clusterId
;
private
String
clusterId
;
...
@@ -87,21 +101,28 @@ public class MsgDTO {
...
@@ -87,21 +101,28 @@ public class MsgDTO {
/**
/**
* 消息类型,0:派工类,1:服务类,2:容量类
* 消息类型,0:派工类,1:服务类,2:容量类
*/
*/
@NotNull
(
message
=
"消息类型不能为空"
)
@Min
(
value
=
0
,
message
=
"消息类型格式不对"
)
@Max
(
value
=
2
,
message
=
"消息类型格式不对"
)
private
Integer
type
;
private
Integer
type
;
/**
/**
* 消息内容
* 消息内容
*/
*/
@NotNull
(
message
=
"消息内容不能为空"
)
private
String
content
;
private
String
content
;
/**
/**
* 单号集合,以
顿号
连接
* 单号集合,以
“、”
连接
*/
*/
private
String
orderIds
;
private
String
orderIds
;
/**
/**
* 标签类型,0:紧急,1:正常
* 标签类型,0:紧急,1:正常
*/
*/
@NotNull
(
message
=
"标签类型不能为空"
)
@Min
(
value
=
0
,
message
=
"标签类型格式不对"
)
@Max
(
value
=
1
,
message
=
"标签类型格式不对"
)
private
Integer
tag
;
private
Integer
tag
;
}
}
}
}
\ No newline at end of file
project-order/src/main/java/com/dituhui/pea/order/dto/MsgResp.java
View file @
bb956ce
...
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
...
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
import
java.util.Date
;
@Data
@Data
...
@@ -70,5 +71,10 @@ public class MsgResp {
...
@@ -70,5 +71,10 @@ public class MsgResp {
*/
*/
private
Integer
isRead
;
private
Integer
isRead
;
/**
* 接收人
*/
private
String
receivers
;
}
}
project-order/src/main/java/com/dituhui/pea/order/entity/MsgEntity.java
View file @
bb956ce
package
com
.
dituhui
.
pea
.
order
.
entity
;
package
com
.
dituhui
.
pea
.
order
.
entity
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -16,6 +17,7 @@ import java.util.Date;
...
@@ -16,6 +17,7 @@ import java.util.Date;
@Entity
@Entity
@Data
@Data
@Table
(
name
=
"zzz_msg"
)
@Table
(
name
=
"zzz_msg"
)
@Accessors
(
chain
=
true
)
public
class
MsgEntity
{
public
class
MsgEntity
{
@Id
@Id
...
...
project-order/src/main/java/com/dituhui/pea/order/entity/MsgReceiverEntity.java
View file @
bb956ce
...
@@ -21,7 +21,7 @@ import java.util.Date;
...
@@ -21,7 +21,7 @@ import java.util.Date;
public
class
MsgReceiverEntity
{
public
class
MsgReceiverEntity
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
int
id
;
private
Integer
id
;
/**
/**
...
...
project-order/src/main/java/com/dituhui/pea/order/entity/OrderInfoEntity.java
View file @
bb956ce
...
@@ -152,10 +152,10 @@ public class OrderInfoEntity {
...
@@ -152,10 +152,10 @@ public class OrderInfoEntity {
private
LocalDateTime
planEndTime
;
private
LocalDateTime
planEndTime
;
@Column
(
name
=
"arrive_elapsed"
,
nullable
=
true
,
columnDefinition
=
"int(11) default '0'"
)
@Column
(
name
=
"arrive_elapsed"
,
nullable
=
true
,
columnDefinition
=
"int(11) default '0'"
)
private
int
arriveElapsed
;
private
Integer
arriveElapsed
;
@Column
(
name
=
"arrive_distance"
,
nullable
=
true
,
columnDefinition
=
"int(11) default '0'"
)
@Column
(
name
=
"arrive_distance"
,
nullable
=
true
,
columnDefinition
=
"int(11) default '0'"
)
private
int
arriveDistance
;
private
Integer
arriveDistance
;
@Column
(
name
=
"actual_start_time"
)
@Column
(
name
=
"actual_start_time"
)
private
LocalDateTime
actualStartTime
;
private
LocalDateTime
actualStartTime
;
...
...
project-order/src/main/java/com/dituhui/pea/order/service/MsgService.java
View file @
bb956ce
...
@@ -3,6 +3,9 @@ package com.dituhui.pea.order.service;
...
@@ -3,6 +3,9 @@ package com.dituhui.pea.order.service;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.order.dto.MsgDTO
;
import
com.dituhui.pea.order.dto.MsgDTO
;
import
com.dituhui.pea.order.dto.MsgGroupResp
;
import
com.dituhui.pea.order.dto.MsgGroupResp
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
public
interface
MsgService
{
public
interface
MsgService
{
...
@@ -25,4 +28,24 @@ public interface MsgService {
...
@@ -25,4 +28,24 @@ public interface MsgService {
* @date 2023/10/24
* @date 2023/10/24
*/
*/
void
delete
(
Integer
msgId
,
String
userId
);
void
delete
(
Integer
msgId
,
String
userId
);
/**
* 设置消息已读
*
* @param msgIds 消息标识
* @param userId 用户标识
* @author RenPing
* @date 2023/10/25
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
void
readMsg
(
List
<
Integer
>
msgIds
,
String
userId
);
/**
* 新增消息
*
* @param dto 参数
* @author RenPing
* @date 2023/10/25
*/
void
add
(
MsgDTO
.
addDto
dto
);
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/MsgServiceImpl.java
View file @
bb956ce
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dituhui.pea.common.PageResult
;
import
com.dituhui.pea.common.PageResult
;
...
@@ -7,19 +8,20 @@ import com.dituhui.pea.order.dao.*;
...
@@ -7,19 +8,20 @@ import com.dituhui.pea.order.dao.*;
import
com.dituhui.pea.order.dto.MsgDTO
;
import
com.dituhui.pea.order.dto.MsgDTO
;
import
com.dituhui.pea.order.dto.MsgGroupResp
;
import
com.dituhui.pea.order.dto.MsgGroupResp
;
import
com.dituhui.pea.order.dto.MsgResp
;
import
com.dituhui.pea.order.dto.MsgResp
;
import
com.dituhui.pea.order.entity.MsgEntity
;
import
com.dituhui.pea.order.entity.MsgReceiverEntity
;
import
com.dituhui.pea.order.entity.MsgReceiverEntity
;
import
com.dituhui.pea.order.entity.OrgBranchEntity
;
import
com.dituhui.pea.order.entity.OrgGroupEntity
;
import
com.dituhui.pea.order.enums.MsgTagEnum
;
import
com.dituhui.pea.order.enums.MsgTagEnum
;
import
com.dituhui.pea.order.enums.MsgTypeEnum
;
import
com.dituhui.pea.order.enums.MsgTypeEnum
;
import
com.dituhui.pea.order.service.MsgService
;
import
com.dituhui.pea.order.service.MsgService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -84,6 +86,47 @@ public class MsgServiceImpl implements MsgService {
...
@@ -84,6 +86,47 @@ public class MsgServiceImpl implements MsgService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Integer
msgId
,
String
userId
)
{
public
void
delete
(
Integer
msgId
,
String
userId
)
{
msgReceiverDao
.
delete
(
msgId
,
userId
);
List
<
MsgReceiverEntity
>
list
=
msgReceiverDao
.
findAll
(
Example
.
of
(
new
MsgReceiverEntity
().
setMsgId
(
msgId
).
setUserId
(
userId
)));
list
.
forEach
(
msgReceiverEntity
->
{
msgReceiverDao
.
deleteById
(
msgReceiverEntity
.
getId
());
});
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
readMsg
(
List
<
Integer
>
msgIds
,
String
userId
)
{
msgReceiverDao
.
read
(
msgIds
,
userId
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
add
(
MsgDTO
.
addDto
dto
)
{
if
(
Objects
.
nonNull
(
dto
.
getGroupId
()))
{
OrgGroupEntity
group
=
groupDao
.
getByGroupId
(
dto
.
getGroupId
());
dto
.
setBranchId
(
group
.
getBranchId
());
dto
.
setClusterId
(
group
.
getClusterId
());
}
else
if
(
Objects
.
nonNull
(
dto
.
getBranchId
()))
{
OrgBranchEntity
branch
=
branchDao
.
getByBranchId
(
dto
.
getBranchId
());
dto
.
setClusterId
(
branch
.
getClusterId
());
}
else
if
(
Objects
.
nonNull
(
dto
.
getClusterId
()))
{
OrgBranchEntity
branch
=
branchDao
.
getByBranchId
(
dto
.
getBranchId
());
dto
.
setClusterId
(
branch
.
getClusterId
());
}
List
<
String
>
userList
=
msgDao
.
getDispatchUserList
(
dto
.
getClusterId
(),
dto
.
getBranchId
(),
dto
.
getGroupId
());
MsgEntity
msgEntity
=
new
MsgEntity
();
BeanUtil
.
copyProperties
(
dto
,
msgEntity
);
msgEntity
.
setCreateTime
(
new
Date
()).
setUpdateTime
(
new
Date
());
msgDao
.
save
(
msgEntity
);
userList
.
forEach
(
userId
->
{
MsgReceiverEntity
msgReceiverEntity
=
new
MsgReceiverEntity
()
.
setMsgId
(
msgEntity
.
getId
())
.
setUserId
(
userId
)
.
setIsRead
(
0
)
.
setCreateTime
(
new
Date
())
.
setUpdateTime
(
new
Date
());
msgReceiverDao
.
save
(
msgReceiverEntity
);
});
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment