Browse Source

发送消息-群组列表、群详情

dev_shibei_match
yinzuomei 4 years ago
parent
commit
c25da91e9b
  1. 2
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/DataSourceConstant.java
  2. 34
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/form/InfoGroupDetailFormDTO.java
  3. 19
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/InfoGroupDetailResDTO.java
  4. 24
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/MyInfoGroupResultDTO.java
  5. 21
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/StaffInfoCommonDTO.java
  6. 37
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/InfoController.java
  7. 29
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetmessage/InfoReceiversDao.java
  8. 26
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/EpmetMessageService.java
  9. 87
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/impl/EpmetMessageServiceImpl.java
  10. 46
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoReceiversDao.xml

2
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/DataSourceConstant.java

@ -32,5 +32,5 @@ public interface DataSourceConstant {
String EVALUATION_INDEX = "evaluationIndex";
String OPERCUSTOMIZE="opercustomize";
String EPMET_MESSAGE="epmentmessage";
String EPMET_MESSAGE="epmetmessage";
}

34
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/form/InfoGroupDetailFormDTO.java

@ -0,0 +1,34 @@
package com.epmet.dataaggre.dto.message.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 群组列表
* @Author yinzuomei
* @Date 2021/8/20 12:54 下午
*/
@Data
public class InfoGroupDetailFormDTO extends PageFormDTO implements Serializable {
@NotBlank(message = "群组id不能为空",groups = PageFormDTO.AddUserInternalGroup.class)
private String receiverGroupId;
//以下参数从token中获取
/**
* 当前用户id
*/
@NotBlank(message = "userId不能为空",groups =PageFormDTO.AddUserInternalGroup.class)
private String userId;
/**
* 当前客户id
*/
@NotBlank(message = "customerId不能为空",groups = PageFormDTO.AddUserInternalGroup.class)
private String customerId;
}

19
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/InfoGroupDetailResDTO.java

@ -0,0 +1,19 @@
package com.epmet.dataaggre.dto.message.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 群组详情
* @Author yinzuomei
* @Date 2021/8/20 12:58 下午
*/
@Data
public class InfoGroupDetailResDTO implements Serializable {
private String receiverGroupId;
private String name;
private List<StaffInfoCommonDTO> staffList;
}

24
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/MyInfoGroupResultDTO.java

@ -0,0 +1,24 @@
package com.epmet.dataaggre.dto.message.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 我创建的群组列表
* @Author yinzuomei
* @Date 2021/8/20 10:30 上午
*/
@Data
public class MyInfoGroupResultDTO implements Serializable {
private static final long serialVersionUID = 3621868560778309056L;
private String receiverGroupId;
private String name;
private Integer totalMem;
@JsonIgnore
private List<String> staffIdList;
private List<String> staffNameList;
}

21
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/message/result/StaffInfoCommonDTO.java

@ -0,0 +1,21 @@
package com.epmet.dataaggre.dto.message.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 工作人员列表基本信息通用吧
* @Author yinzuomei
* @Date 2021/8/20 1:02 下午
*/
@Data
public class StaffInfoCommonDTO implements Serializable {
private String staffId;
private String staffName;
private String gender;
private String orgName;
private String headPhoto;
}

37
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/InfoController.java

@ -1,9 +1,15 @@
package com.epmet.dataaggre.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dataaggre.dto.govorg.form.ReceiversFormDTO;
import com.epmet.dataaggre.dto.govorg.result.ReceiversResultDTO;
import com.epmet.dataaggre.dto.message.form.InfoGroupDetailFormDTO;
import com.epmet.dataaggre.dto.message.result.InfoGroupDetailResDTO;
import com.epmet.dataaggre.dto.message.result.MyInfoGroupResultDTO;
import com.epmet.dataaggre.service.epmetmessage.EpmetMessageService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -11,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @Description
@ -37,4 +44,34 @@ public class InfoController {
return new Result<ReceiversResultDTO>().ok(result);
}
/**
* 发送消息-我创建的群组列表
*
* @param tokenDto
* @return com.epmet.commons.tools.utils.Result<List<MyInfoGroupResultDTO>>
* @author yinzuomei
* @date 2021/8/20 10:32 上午
*/
@PostMapping("grouplist")
public Result<List<MyInfoGroupResultDTO>> queryMyGroupList(@LoginUser TokenDto tokenDto){
return new Result<List<MyInfoGroupResultDTO>>().ok(epmetMessageService.queryMyGroupList(tokenDto.getUserId(),tokenDto.getCustomerId()));
}
/**
* 发送消息-群组详情
*
* @param tokenDto
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dataaggre.dto.message.result.InfoGroupDetailResDTO>
* @author yinzuomei
* @date 2021/8/20 12:59 下午
*/
@PostMapping("groupdetail")
public Result<InfoGroupDetailResDTO> queryGroupDetail(@LoginUser TokenDto tokenDto, @RequestBody InfoGroupDetailFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
formDTO.setUserId(tokenDto.getUserId());
ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class);
return new Result<InfoGroupDetailResDTO>().ok(epmetMessageService.queryGroupDetail(formDTO));
}
}

29
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetmessage/InfoReceiversDao.java

@ -18,8 +18,12 @@
package com.epmet.dataaggre.dao.epmetmessage;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.message.result.MyInfoGroupResultDTO;
import com.epmet.dataaggre.entity.epmetmessage.InfoReceiversEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 消息接收人记录表
@ -29,5 +33,28 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface InfoReceiversDao extends BaseDao<InfoReceiversEntity> {
/**
* 我创建的群组列表
*
* @param staffId
* @param customerId
* @return java.util.List<com.epmet.dataaggre.dto.message.result.MyInfoGroupResultDTO>
* @author yinzuomei
* @date 2021/8/20 10:37 上午
*/
List<MyInfoGroupResultDTO> selectMyGroupList(@Param("staffId") String staffId,@Param("customerId") String customerId,@Param("receiverGroupId")String receiverGroupId);
/**
* 我创建的组内所有的人
*
* @param staffId
* @param customerId
* @return java.util.List<java.lang.String>
* @author yinzuomei
* @date 2021/8/20 10:46 上午
*/
List<String> selectDistinctStaffIds(@Param("staffId") String staffId,
@Param("customerId") String customerId,
@Param("receiverGroupId")String receiverGroupId);
}

26
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/EpmetMessageService.java

@ -2,6 +2,11 @@ package com.epmet.dataaggre.service.epmetmessage;
import com.epmet.dataaggre.dto.govorg.form.ReceiversFormDTO;
import com.epmet.dataaggre.dto.govorg.result.ReceiversResultDTO;
import com.epmet.dataaggre.dto.message.form.InfoGroupDetailFormDTO;
import com.epmet.dataaggre.dto.message.result.InfoGroupDetailResDTO;
import com.epmet.dataaggre.dto.message.result.MyInfoGroupResultDTO;
import java.util.List;
/**
* @author Administrator
@ -15,4 +20,25 @@ public interface EpmetMessageService {
* @Date 2021/8/19 14:56
*/
ReceiversResultDTO getReceiverList(ReceiversFormDTO formDTO);
/**
* 我创建的群组列表
*
* @param staffId
* @param customerId
* @return java.util.List<com.epmet.dataaggre.dto.message.result.MyInfoGroupResultDTO>
* @author yinzuomei
* @date 2021/8/20 10:33 上午
*/
List<MyInfoGroupResultDTO> queryMyGroupList(String staffId, String customerId);
/**
* 发送消息-群组详情
*
* @param formDTO
* @return com.epmet.dataaggre.dto.message.result.InfoGroupDetailResDTO
* @author yinzuomei
* @date 2021/8/20 12:59 下午
*/
InfoGroupDetailResDTO queryGroupDetail(InfoGroupDetailFormDTO formDTO);
}

87
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetmessage/impl/EpmetMessageServiceImpl.java

@ -5,19 +5,27 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoCache;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.epmetmessage.InfoReceiversDao;
import com.epmet.dataaggre.dto.govorg.ReceiverDTO;
import com.epmet.dataaggre.dto.govorg.form.ReceiversFormDTO;
import com.epmet.dataaggre.dto.govorg.result.ReceiversResultDTO;
import com.epmet.dataaggre.dto.message.form.InfoGroupDetailFormDTO;
import com.epmet.dataaggre.dto.message.result.InfoGroupDetailResDTO;
import com.epmet.dataaggre.dto.message.result.MyInfoGroupResultDTO;
import com.epmet.dataaggre.dto.message.result.StaffInfoCommonDTO;
import com.epmet.dataaggre.entity.epmetmessage.InfoReceiversEntity;
import com.epmet.dataaggre.service.epmetmessage.EpmetMessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -31,9 +39,10 @@ import java.util.stream.Collectors;
@DataSource(DataSourceConstant.EPMET_MESSAGE)
@Slf4j
public class EpmetMessageServiceImpl implements EpmetMessageService {
@Resource
@Autowired
private InfoReceiversDao infoReceiversDao;
@Autowired
private CustomerStaffRedis customerStaffRedis;
/**
* @param formDTO
@ -70,4 +79,76 @@ public class EpmetMessageServiceImpl implements EpmetMessageService {
result.setDataList(dataList);
return result;
}
/**
* 我创建的群组列表
*
* @param staffId
* @param customerId
* @return java.util.List<com.epmet.dataaggre.dto.message.result.MyInfoGroupResultDTO>
* @author yinzuomei
* @date 2021/8/20 10:33 上午
*/
@Override
public List<MyInfoGroupResultDTO> queryMyGroupList(String staffId, String customerId) {
List<MyInfoGroupResultDTO> list = infoReceiversDao.selectMyGroupList(staffId, customerId,null);
if (CollectionUtils.isNotEmpty(list)) {
// 2、遍历每个群组,赋值工作人员姓名列表
for (MyInfoGroupResultDTO group : list) {
List<String> staffNameList = new ArrayList<>();
for (String userId : group.getStaffIdList()) {
//查询每个工作人员的基本信息,获取姓名
CustomerStaffInfoCache staffInfoCache = customerStaffRedis.getStaffInfo(customerId, userId);
if (null != staffInfoCache) {
staffNameList.add(staffInfoCache.getRealName());
}
}
group.setStaffNameList(staffNameList);
}
}
return list;
}
/**
* 发送消息-群组详情
*
* @param formDTO
* @return com.epmet.dataaggre.dto.message.result.InfoGroupDetailResDTO
* @author yinzuomei
* @date 2021/8/20 12:59 下午
*/
@Override
public InfoGroupDetailResDTO queryGroupDetail(InfoGroupDetailFormDTO formDTO) {
List<MyInfoGroupResultDTO> list = infoReceiversDao.selectMyGroupList(formDTO.getUserId(), formDTO.getCustomerId(),formDTO.getReceiverGroupId());
InfoGroupDetailResDTO resDTO = new InfoGroupDetailResDTO();
if (CollectionUtils.isNotEmpty(list)) {
// 2、遍历每个群组,赋值工作人员姓名列表
for (MyInfoGroupResultDTO group : list) {
resDTO.setReceiverGroupId(group.getReceiverGroupId());
resDTO.setName(group.getName());
List<StaffInfoCommonDTO> staffList=new ArrayList<>();
for (String userId : group.getStaffIdList()) {
//查询每个工作人员的基本信息
CustomerStaffInfoCache staffInfoCache = customerStaffRedis.getStaffInfo(formDTO.getCustomerId(), userId);
if (null != staffInfoCache) {
StaffInfoCommonDTO staffInfo=new StaffInfoCommonDTO();
staffInfo.setStaffId(userId);
staffInfo.setStaffName(staffInfoCache.getRealName());
staffInfo.setGender(staffInfoCache.getGender().toString());
staffInfo.setHeadPhoto(StringUtils.isNotBlank(staffInfoCache.getHeadPhoto())?staffInfoCache.getHeadPhoto(): StrConstant.EPMETY_STR);
// 从网格添加的,显示 XXX-网格名
// 部门添加的,显示XXX-部门名
// 组织添加的,XXX组织名-XXX组织名
String showOrgName="todo";
//todo
staffInfo.setOrgName(showOrgName);
staffList.add(staffInfo);
}
}
resDTO.setStaffList(staffList);
}
}
return resDTO;
}
}

46
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoReceiversDao.xml

@ -3,6 +3,50 @@
<mapper namespace="com.epmet.dataaggre.dao.epmetmessage.InfoReceiversDao">
<resultMap id="MyInfoGroupResultDTOMap" type="com.epmet.dataaggre.dto.message.result.MyInfoGroupResultDTO">
<result property="receiverGroupId" column="receiverGroupId"/>
<result property="name" column="name"/>
<result property="totalMem" column="totalMem"/>
<collection property="staffIdList" ofType="java.lang.String">
<result column="staffId"/>
</collection>
</resultMap>
<!-- 我创建的群组列表 -->
<select id="selectMyGroupList" parameterType="map" resultMap="MyInfoGroupResultDTOMap">
SELECT
irg.ID as receiverGroupId,
irg.`NAME` as name,
( SELECT count( igr.id ) FROM info_group_receivers igr WHERE igr.DEL_FLAG = '0' AND igr.info_receiver_group_id = irg.id ) AS totalMem,
igr.STAFF_ID as staffId
FROM
info_receiver_group irg
left join info_group_receivers igr
on(irg.id=igr.info_receiver_group_id and igr.DEL_FLAG='0')
WHERE
irg.DEL_FLAG = '0'
AND irg.CREATE_STAFF_ID = #{staffId}
AND irg.CUSTOMER_ID = #{customerId}
<if test="null != receiverGroupId and receiverGroupId !=''">
and irg.id=#{receiverGroupId}
</if>
order by irg.CREATED_TIME asc
</select>
<!-- 我创建的组内所有的人 -->
<select id="selectDistinctStaffIds" parameterType="map" resultType="java.lang.String">
SELECT DISTINCT
igr.STAFF_ID
FROM
info_group_receivers igr
LEFT JOIN info_receiver_group irg ON ( igr.info_receiver_group_id = irg.id )
WHERE
igr.DEL_FLAG = '0'
AND igr.CUSTOMER_ID = #{customerId}
AND irg.DEL_FLAG = '0'
AND irg.CUSTOMER_ID = #{customerId}
AND irg.CREATE_STAFF_ID = #{staffId}
<if test="null != receiverGroupId and receiverGroupId !=''">
AND irg.id =#{receiverGroupId}
</if>
</select>
</mapper>
Loading…
Cancel
Save