forked from rongchao/epmet-cloud-rizhao
37 changed files with 1071 additions and 22 deletions
@ -0,0 +1,52 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.Valid; |
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotEmpty; |
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
|
|||
/** |
|||
* 组织发布消息(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
@Data |
|||
public class OrganizationMessageFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public interface AddShowGroup extends CustomerClientShowGroup { |
|||
} |
|||
/** |
|||
* 发布渠道:0:专属app |
|||
*/ |
|||
@NotBlank(message = "发布渠道不能为空", groups = {AddShowGroup.class}) |
|||
private String publishDitch; |
|||
|
|||
/** |
|||
* 消息内容;最多输入500 |
|||
*/ |
|||
@NotBlank(message = "内容不能为空", groups = {AddShowGroup.class}) |
|||
@Length(max = 500, message = "内容输入500字", groups = {AddShowGroup.class}) |
|||
private String content; |
|||
|
|||
@Valid |
|||
@NotEmpty(message = "发布范围不能为空", groups = {AddShowGroup.class}) |
|||
private List<OrganizationMessagePublishRangeDTO> rangeList; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
/** |
|||
* 发布人staffId |
|||
*/ |
|||
private String publishStaffId; |
|||
} |
@ -0,0 +1,63 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
/** |
|||
* 消息发布范围(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
@Data |
|||
public class OrganizationMessagePublishRangeDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 消息id:organization_message.id |
|||
*/ |
|||
private String messageId; |
|||
|
|||
/** |
|||
* 组织或者网格id |
|||
*/ |
|||
@NotBlank(message = "orgId不能为空",groups = {OrganizationMessageFormDTO.AddShowGroup.class}) |
|||
private String orgId; |
|||
|
|||
/** |
|||
* 组织:agency;网格:grid |
|||
*/ |
|||
@NotBlank(message = "orgType不能为空",groups = {OrganizationMessageFormDTO.AddShowGroup.class}) |
|||
private String orgType; |
|||
|
|||
/** |
|||
* org_id的父级 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* org_id的全路径,包含org_id |
|||
*/ |
|||
private String orgIdPath; |
|||
|
|||
/** |
|||
* 组织名称或者网格名称;如果是网格名称,存储的是XXX社区-XX网格 |
|||
*/ |
|||
private String orgName; |
|||
|
|||
|
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 烟台消息管理,列表查询入参 |
|||
* @Author yzm |
|||
* @Date 2023/5/4 16:05 |
|||
*/ |
|||
@Data |
|||
public class OrganizationMessagePageFormDTO extends PageFormDTO { |
|||
/** |
|||
* 发布渠道:0:专属app |
|||
*/ |
|||
private String publishDitch; |
|||
/** |
|||
* 发布范围,组织id或者网格id |
|||
*/ |
|||
private String orgId; |
|||
/** |
|||
* yyyy-MM-dd |
|||
*/ |
|||
private String startDate; |
|||
/** |
|||
* yyyy-MM-dd |
|||
*/ |
|||
private String endDate; |
|||
} |
|||
|
@ -0,0 +1,84 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.epmet.dto.OrganizationMessagePublishRangeDTO; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 烟台消息管理,列表查询 |
|||
* @Author yzm |
|||
* @Date 2023/5/4 16:06 |
|||
*/ |
|||
@Data |
|||
public class OrganizationMessageResultDTO { |
|||
/** |
|||
* 消息id |
|||
*/ |
|||
private String messageId; |
|||
|
|||
/** |
|||
* 发布渠道:0:专属app |
|||
*/ |
|||
private String publishDitch; |
|||
|
|||
/** |
|||
* 消息内容;最多输入500 |
|||
*/ |
|||
private String content; |
|||
/** |
|||
* 发布范围 |
|||
*/ |
|||
private String publishRangeName; |
|||
|
|||
/** |
|||
* 发布时间 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date publishTime; |
|||
|
|||
/** |
|||
* 发布人staffId |
|||
*/ |
|||
private String publishStaffId; |
|||
|
|||
/** |
|||
* 发布人姓名 |
|||
*/ |
|||
private String publishStaffName; |
|||
|
|||
/** |
|||
* 发布人所属组织id |
|||
*/ |
|||
private String publishOrgId; |
|||
|
|||
/** |
|||
* org_id_path |
|||
*/ |
|||
private String publishOrgIdPath; |
|||
|
|||
/** |
|||
* 发布人所属组织名称 |
|||
*/ |
|||
private String publishOrgName; |
|||
|
|||
/** |
|||
* 发送结果 |
|||
*/ |
|||
private String sendMsgRes; |
|||
/** |
|||
* 共发送出多少条消息 |
|||
*/ |
|||
private Integer totalReceiver; |
|||
|
|||
/** |
|||
* 发送完成时间 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date finishSendTime; |
|||
|
|||
private List<OrganizationMessagePublishRangeDTO> rangeList; |
|||
} |
|||
|
@ -0,0 +1,76 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
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.dto.OrganizationMessageFormDTO; |
|||
import com.epmet.dto.form.OrganizationMessagePageFormDTO; |
|||
import com.epmet.dto.result.OrganizationMessageResultDTO; |
|||
import com.epmet.service.OrganizationMessageService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
|
|||
/** |
|||
* 组织发布消息(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("organization/message") |
|||
public class OrganizationMessageController { |
|||
|
|||
@Autowired |
|||
private OrganizationMessageService organizationMessageService; |
|||
|
|||
/** |
|||
* 列表查询 |
|||
* |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("list") |
|||
public Result<PageData<OrganizationMessageResultDTO>> pageList(@RequestBody OrganizationMessagePageFormDTO formDTO) { |
|||
return new Result<PageData<OrganizationMessageResultDTO>>().ok(organizationMessageService.pageList(formDTO.getPageNo(), formDTO.getPageSize(), |
|||
formDTO.getPublishDitch(), |
|||
formDTO.getOrgId(), |
|||
formDTO.getStartDate(), |
|||
formDTO.getEndDate())); |
|||
} |
|||
|
|||
/** |
|||
* 查询消息详情 |
|||
* |
|||
* @param messageId |
|||
* @return |
|||
*/ |
|||
@PostMapping("detail/{messageId}") |
|||
public Result<OrganizationMessageResultDTO> getDetail(@PathVariable("messageId") String messageId) { |
|||
if (StringUtils.isBlank(messageId)) { |
|||
return new Result<>(); |
|||
} |
|||
return new Result<OrganizationMessageResultDTO>().ok(organizationMessageService.getDetail(messageId)); |
|||
} |
|||
|
|||
/** |
|||
* 发布消息 |
|||
* |
|||
* @param formDTO |
|||
* @return 返回消息id |
|||
*/ |
|||
@PostMapping("publish") |
|||
public Result publish(@LoginUser TokenDto tokenDto, @RequestBody OrganizationMessageFormDTO formDTO) { |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setPublishStaffId(tokenDto.getUserId()); |
|||
ValidatorUtils.validateEntity(formDTO, OrganizationMessageFormDTO.AddShowGroup.class); |
|||
String messageId=organizationMessageService.publish(formDTO); |
|||
// 发送消息 发布范围下有哪些网格,网格下所有的注册居民,每人发送一条消息
|
|||
organizationMessageService.sendUserMsg(messageId,formDTO.getContent(),formDTO.getPublishStaffId(),formDTO.getRangeList(),formDTO.getCustomerId()); |
|||
return new Result().ok(messageId); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.result.OrganizationMessageResultDTO; |
|||
import com.epmet.entity.OrganizationMessageEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 组织发布消息(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
@Mapper |
|||
public interface OrganizationMessageDao extends BaseDao<OrganizationMessageEntity> { |
|||
|
|||
/** |
|||
* |
|||
* @param staffOrgIdPath 工作人员所属组织的orgIdPath |
|||
* @param publishDitch 发布渠道;0:专属app |
|||
* @param orgId 发布范围,组织id或者网格id |
|||
* @param startDate yyyy-MM-dd |
|||
* @param endDate yyyy-MM-dd |
|||
* @return |
|||
*/ |
|||
List<OrganizationMessageResultDTO> pageList(@Param("customerId")String customerId, |
|||
@Param("staffOrgIdPath") String staffOrgIdPath, |
|||
@Param("publishDitch")String publishDitch, |
|||
@Param("orgId")String orgId, |
|||
@Param("startDate")String startDate, |
|||
@Param("endDate")String endDate, |
|||
@Param("messageId")String messageId); |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.OrganizationMessagePublishRangeEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 消息发布范围(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
@Mapper |
|||
public interface OrganizationMessagePublishRangeDao extends BaseDao<OrganizationMessagePublishRangeEntity> { |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 组织发布消息(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("organization_message") |
|||
public class OrganizationMessageEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 发布渠道:0:专属app |
|||
*/ |
|||
private String publishDitch; |
|||
|
|||
/** |
|||
* 消息内容;最多输入500 |
|||
*/ |
|||
private String content; |
|||
|
|||
/** |
|||
* 发布人staffId |
|||
*/ |
|||
private String publishStaffId; |
|||
|
|||
/** |
|||
* 发布人姓名 |
|||
*/ |
|||
private String publishStaffName; |
|||
|
|||
/** |
|||
* 发布人所属组织id |
|||
*/ |
|||
private String publishOrgId; |
|||
|
|||
/** |
|||
* org_id_path |
|||
*/ |
|||
private String publishOrgIdPath; |
|||
|
|||
/** |
|||
* 发布人所属组织名称 |
|||
*/ |
|||
private String publishOrgName; |
|||
|
|||
/** |
|||
* 发布时间 |
|||
*/ |
|||
private Date publishTime; |
|||
/** |
|||
* 发送结果 |
|||
* sending发送中;failed失败;success成功 |
|||
*/ |
|||
private String sendMsgRes; |
|||
/** |
|||
* 共发送出多少条消息 |
|||
*/ |
|||
private Integer totalReceiver; |
|||
|
|||
/** |
|||
* 发送完成时间 |
|||
*/ |
|||
private Date finishSendTime; |
|||
} |
@ -0,0 +1,56 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 消息发布范围(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("organization_message_publish_range") |
|||
public class OrganizationMessagePublishRangeEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 消息id:organization_message.id |
|||
*/ |
|||
private String messageId; |
|||
|
|||
/** |
|||
* 组织或者网格id |
|||
*/ |
|||
private String orgId; |
|||
|
|||
/** |
|||
* 组织:agency;网格:grid |
|||
*/ |
|||
private String orgType; |
|||
|
|||
/** |
|||
* org_id的父级 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* org_id的全路径,包含org_id |
|||
*/ |
|||
private String orgIdPath; |
|||
|
|||
/** |
|||
* 组织名称或者网格名称;如果是网格名称,存储的是XXX社区-XX网格 |
|||
*/ |
|||
private String orgName; |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.OrganizationMessageFormDTO; |
|||
import com.epmet.dto.OrganizationMessagePublishRangeDTO; |
|||
import com.epmet.dto.result.OrganizationMessageResultDTO; |
|||
import com.epmet.entity.OrganizationMessageEntity; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 组织发布消息(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
public interface OrganizationMessageService extends BaseService<OrganizationMessageEntity> { |
|||
|
|||
/** |
|||
* 分页列表 |
|||
* @param pageNo |
|||
* @param pageSize |
|||
* @param publishDitch 发布渠道;0:专属app |
|||
* @param orgId 发布范围,组织id或者网格id |
|||
* @param startDate yyyy-MM-dd |
|||
* @param endDate yyyy-MM-dd |
|||
* @return |
|||
*/ |
|||
PageData<OrganizationMessageResultDTO> pageList(Integer pageNo, Integer pageSize, String publishDitch, String orgId, String startDate, String endDate); |
|||
|
|||
/** |
|||
* 查询详情 |
|||
* @param messageId |
|||
* @return |
|||
*/ |
|||
OrganizationMessageResultDTO getDetail(String messageId); |
|||
|
|||
/** |
|||
* 发布消息 |
|||
* @param formDTO |
|||
* @return 返回消息id |
|||
*/ |
|||
String publish(OrganizationMessageFormDTO formDTO); |
|||
|
|||
void sendUserMsg(String messageId, String content, String publishStaffId, List<OrganizationMessagePublishRangeDTO> rangeList, String customerId); |
|||
} |
@ -0,0 +1,219 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.AppClientConstant; |
|||
import com.epmet.commons.tools.constant.Constant; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.constant.StrConstant; |
|||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|||
import com.epmet.commons.tools.enums.OrgTypeEnum; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|||
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|||
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|||
import com.epmet.commons.tools.utils.*; |
|||
import com.epmet.dao.OrganizationMessageDao; |
|||
import com.epmet.dao.OrganizationMessagePublishRangeDao; |
|||
import com.epmet.dao.UserMessageDao; |
|||
import com.epmet.dto.OrganizationMessageFormDTO; |
|||
import com.epmet.dto.OrganizationMessagePublishRangeDTO; |
|||
import com.epmet.dto.RegisterRelationDTO; |
|||
import com.epmet.dto.form.RegisterRelationPageFormDTO; |
|||
import com.epmet.dto.result.OrganizationMessageResultDTO; |
|||
import com.epmet.entity.OrganizationMessageEntity; |
|||
import com.epmet.entity.OrganizationMessagePublishRangeEntity; |
|||
import com.epmet.entity.UserMessageEntity; |
|||
import com.epmet.feign.EpmetUserOpenFeignClient; |
|||
import com.epmet.service.OrganizationMessageService; |
|||
import com.github.pagehelper.PageHelper; |
|||
import com.github.pagehelper.PageInfo; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.scheduling.annotation.Async; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 组织发布消息(烟台) |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-05-04 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class OrganizationMessageServiceImpl extends BaseServiceImpl<OrganizationMessageDao, OrganizationMessageEntity> implements OrganizationMessageService { |
|||
@Autowired |
|||
private OrganizationMessagePublishRangeDao organizationMessagePublishRangeDao; |
|||
@Autowired |
|||
private UserMessageDao userMessageDao; |
|||
@Autowired |
|||
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|||
|
|||
|
|||
/** |
|||
* 分页列表 |
|||
* |
|||
* @param pageNo |
|||
* @param pageSize |
|||
* @param publishDitch 发布渠道;0:专属app |
|||
* @param orgId 发布范围,组织id或者网格id |
|||
* @param startDate yyyy-MM-dd |
|||
* @param endDate yyyy-MM-dd |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public PageData<OrganizationMessageResultDTO> pageList(Integer pageNo, Integer pageSize, String publishDitch, String orgId, String startDate, String endDate) { |
|||
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), EpmetRequestHolder.getLoginUserId()); |
|||
if (null == staffInfoCacheResult) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "customerId:" + EpmetRequestHolder.getLoginUserCustomerId() + "staffId:" + EpmetRequestHolder.getLoginUserId(), "获取工作人员信息异常"); |
|||
} |
|||
String staffOrgIdPath = PidUtils.convertPid2OrgIdPath(staffInfoCacheResult.getAgencyId(), staffInfoCacheResult.getAgencyPIds()); |
|||
PageHelper.startPage(pageNo, pageSize); |
|||
List<OrganizationMessageResultDTO> list = baseDao.pageList(EpmetRequestHolder.getLoginUserCustomerId(),staffOrgIdPath, publishDitch, orgId, startDate, endDate,null); |
|||
PageInfo<OrganizationMessageResultDTO> pageInfo = new PageInfo<>(list); |
|||
return new PageData<>(list, pageInfo.getTotal(),pageSize); |
|||
} |
|||
|
|||
/** |
|||
* 查询详情 |
|||
* |
|||
* @param messageId |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public OrganizationMessageResultDTO getDetail(String messageId) { |
|||
List<OrganizationMessageResultDTO> list = baseDao.pageList(EpmetRequestHolder.getLoginUserCustomerId(),null, null, null, null, null,messageId); |
|||
if(CollectionUtils.isNotEmpty(list)){ |
|||
OrganizationMessageResultDTO resultDTO=list.get(NumConstant.ZERO); |
|||
LambdaQueryWrapper<OrganizationMessagePublishRangeEntity> queryWrapper=new LambdaQueryWrapper<>(); |
|||
queryWrapper.eq(OrganizationMessagePublishRangeEntity::getMessageId,messageId) |
|||
.orderByAsc(OrganizationMessagePublishRangeEntity::getCreatedTime); |
|||
List<OrganizationMessagePublishRangeEntity> rangeList=organizationMessagePublishRangeDao.selectList(queryWrapper); |
|||
resultDTO.setRangeList(ConvertUtils.sourceToTarget(rangeList,OrganizationMessagePublishRangeDTO.class)); |
|||
return resultDTO; |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 发布消息 |
|||
* |
|||
* @param formDTO |
|||
* @return 返回消息id |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public String publish(OrganizationMessageFormDTO formDTO) { |
|||
OrganizationMessageEntity messageEntity = ConvertUtils.sourceToTarget(formDTO, OrganizationMessageEntity.class); |
|||
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getPublishStaffId()); |
|||
messageEntity.setPublishStaffName(staffInfoCacheResult.getRealName()); |
|||
messageEntity.setPublishOrgId(staffInfoCacheResult.getAgencyId()); |
|||
messageEntity.setPublishOrgIdPath(PidUtils.convertPid2OrgIdPath(staffInfoCacheResult.getAgencyId(), staffInfoCacheResult.getAgencyPIds())); |
|||
messageEntity.setPublishOrgName(staffInfoCacheResult.getAgencyName()); |
|||
messageEntity.setPublishTime(new Date()); |
|||
messageEntity.setSendMsgRes("sending"); |
|||
baseDao.insert(messageEntity); |
|||
for (OrganizationMessagePublishRangeDTO dto : formDTO.getRangeList()) { |
|||
OrganizationMessagePublishRangeEntity rangeEntity = new OrganizationMessagePublishRangeEntity(); |
|||
rangeEntity.setCustomerId(messageEntity.getCustomerId()); |
|||
rangeEntity.setMessageId(messageEntity.getId()); |
|||
rangeEntity.setOrgId(dto.getOrgId()); |
|||
rangeEntity.setOrgType(dto.getOrgType()); |
|||
if (OrgTypeEnum.GRID.getCode().equals(dto.getOrgType())) { |
|||
GridInfoCache gridInfoCache = CustomerOrgRedis.getGridInfo(dto.getOrgId()); |
|||
rangeEntity.setPid(gridInfoCache.getPid()); |
|||
rangeEntity.setOrgIdPath(PidUtils.convertPid2OrgIdPath(dto.getOrgId(), gridInfoCache.getPids())); |
|||
rangeEntity.setOrgName(gridInfoCache.getGridNamePath()); |
|||
} else { |
|||
//if (OrgTypeEnum.AGENCY.getCode().equals(dto.getOrgType()))
|
|||
AgencyInfoCache agencyInfoCache = CustomerOrgRedis.getAgencyInfo(dto.getOrgId()); |
|||
rangeEntity.setPid(agencyInfoCache.getPid()); |
|||
rangeEntity.setOrgIdPath(PidUtils.convertPid2OrgIdPath(dto.getOrgId(), agencyInfoCache.getPids())); |
|||
rangeEntity.setOrgName(agencyInfoCache.getOrganizationName()); |
|||
} |
|||
dto.setPid(rangeEntity.getPid()); |
|||
dto.setOrgIdPath(rangeEntity.getOrgIdPath()); |
|||
organizationMessagePublishRangeDao.insert(rangeEntity); |
|||
} |
|||
String messageId = messageEntity.getId(); |
|||
return messageId; |
|||
} |
|||
|
|||
|
|||
@Async |
|||
@Override |
|||
public void sendUserMsg(String messageId, String content, String publishStaffId,List<OrganizationMessagePublishRangeDTO> rangeList, String customerId) { |
|||
String result = "success"; |
|||
int totalMsg = NumConstant.ZERO; |
|||
try { |
|||
for (OrganizationMessagePublishRangeDTO rangeDto : rangeList) { |
|||
RegisterRelationPageFormDTO pageFormDTO=new RegisterRelationPageFormDTO(); |
|||
pageFormDTO.setCustomerId(customerId); |
|||
pageFormDTO.setFirstRegister(NumConstant.ONE_STR); |
|||
pageFormDTO.setPageNo(NumConstant.ONE); |
|||
pageFormDTO.setPageSize(NumConstant.TWO); |
|||
// pageFormDTO.setPageSize(NumConstant.ONE_THOUSAND);
|
|||
if (OrgTypeEnum.GRID.getCode().equals(rangeDto.getOrgType())) { |
|||
// 查询该网格下的注册居民
|
|||
pageFormDTO.setGridId(rangeDto.getOrgId()); |
|||
} else { |
|||
// 查询该组织下的注册居民
|
|||
pageFormDTO.setAgencyIdPath(rangeDto.getOrgIdPath()); |
|||
} |
|||
List<RegisterRelationDTO> list=null; |
|||
do { |
|||
Result<PageData<RegisterRelationDTO>> regRes = epmetUserOpenFeignClient.pageQueryRegisterUser(pageFormDTO); |
|||
list = regRes.getData().getList(); |
|||
for (RegisterRelationDTO regUser : list) { |
|||
LambdaQueryWrapper<UserMessageEntity> queryWrapper=new LambdaQueryWrapper(); |
|||
queryWrapper.eq(UserMessageEntity::getCustomerId,customerId) |
|||
.eq(UserMessageEntity::getTargetId,messageId) |
|||
.eq(UserMessageEntity::getUserId,regUser.getUserId()); |
|||
UserMessageEntity origin=userMessageDao.selectOne(queryWrapper); |
|||
if(null==origin){ |
|||
UserMessageEntity userMessageEntity = new UserMessageEntity(); |
|||
userMessageEntity.setCustomerId(customerId); |
|||
userMessageEntity.setGridId(regUser.getGridId()); |
|||
userMessageEntity.setUserId(regUser.getUserId()); |
|||
userMessageEntity.setApp(AppClientConstant.APP_RESI); |
|||
userMessageEntity.setTitle("您有一条社区消息!"); |
|||
userMessageEntity.setMessageContent(content); |
|||
userMessageEntity.setReadFlag(Constant.UNREAD); |
|||
userMessageEntity.setReferer(StrConstant.EPMETY_STR); |
|||
userMessageEntity.setMessageType("organization_message"); |
|||
userMessageEntity.setTargetId(messageId); |
|||
userMessageEntity.setCreatedBy(publishStaffId); |
|||
userMessageEntity.setUpdatedBy(publishStaffId); |
|||
userMessageDao.insert(userMessageEntity); |
|||
totalMsg += 1; |
|||
} |
|||
} |
|||
pageFormDTO.setPageNo(pageFormDTO.getPageNo() + NumConstant.ONE); |
|||
} while (CollectionUtils.isNotEmpty(list) && list.size() == pageFormDTO.getPageSize()); |
|||
} |
|||
} catch (Exception e) { |
|||
log.error(String.format("messageId:%s,发送消息异常:%s", messageId, ExceptionUtils.getErrorStackTrace(e))); |
|||
result = "failed"; |
|||
} finally { |
|||
LambdaUpdateWrapper<OrganizationMessageEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|||
updateWrapper.eq(OrganizationMessageEntity::getId, messageId) |
|||
.set(OrganizationMessageEntity::getSendMsgRes, result) |
|||
.set(OrganizationMessageEntity::getTotalReceiver, totalMsg) |
|||
.set(OrganizationMessageEntity::getFinishSendTime,new Date()) |
|||
.set(OrganizationMessageEntity::getUpdatedTime,new Date()); |
|||
baseDao.update(null, updateWrapper); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,66 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.OrganizationMessageDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.OrganizationMessageEntity" id="organizationMessageMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="publishDitch" column="PUBLISH_DITCH"/> |
|||
<result property="content" column="CONTENT"/> |
|||
<result property="publishStaffId" column="PUBLISH_STAFF_ID"/> |
|||
<result property="publishStaffName" column="PUBLISH_STAFF_NAME"/> |
|||
<result property="publishOrgId" column="PUBLISH_ORG_ID"/> |
|||
<result property="publishOrgIdPath" column="PUBLISH_ORG_ID_PATH"/> |
|||
<result property="publishOrgName" column="PUBLISH_ORG_NAME"/> |
|||
<result property="publishTime" column="PUBLISH_TIME"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<select id="pageList" parameterType="map" resultType="com.epmet.dto.result.OrganizationMessageResultDTO"> |
|||
select |
|||
distinct om.ID as messageId, |
|||
om.PUBLISH_DITCH as publishDitch, |
|||
om.CONTENT as content, |
|||
om.PUBLISH_TIME as publishTime, |
|||
om.PUBLISH_STAFF_ID as publishStaffId, |
|||
om.PUBLISH_ORG_ID as publishStaffName, |
|||
om.PUBLISH_ORG_ID as publishOrgId, |
|||
om.PUBLISH_ORG_ID_PATH as publishOrgIdPath, |
|||
OM.PUBLISH_ORG_NAME as publishOrgName, |
|||
om.SEND_MSG_RES as sendMsgRes, |
|||
om.TOTAL_RECEIVER as totalReceiver, |
|||
om.FINISH_SEND_TIME as finishSendTime, |
|||
GROUP_CONCAT(r.ORG_NAME) as publishRangeName |
|||
from organization_message om |
|||
left join organization_message_publish_range r |
|||
on(om.id=r.MESSAGE_ID and r.del_flag='0') |
|||
where om.DEL_FLAG='0' |
|||
and om.CUSTOMER_ID =#{customerId} |
|||
<if test='staffOrgIdPath != null and staffOrgIdPath != "" '> |
|||
and om.PUBLISH_ORG_ID_PATH like concat(#{staffOrgIdPath},'%') |
|||
</if> |
|||
<if test='publishDitch != null and publishDitch != "" '> |
|||
and om.PUBLISH_DITCH =#{publishDitch} |
|||
</if> |
|||
<if test='orgId != null and orgId != "" '> |
|||
and r.ORG_ID =#{orgId} |
|||
</if> |
|||
<if test='startDate != null and startDate != "" '> |
|||
AND DATE_FORMAT(om.PUBLISH_TIME,'%Y-%m-%d') >= #{startDate} |
|||
</if> |
|||
<if test='endDate != null and endDate != "" '> |
|||
AND DATE_FORMAT(om.PUBLISH_TIME,'%Y-%m-%d') <![CDATA[ <= ]]> #{endDate} |
|||
</if> |
|||
<if test='messageId != null and messageId != "" '> |
|||
and om.id =#{messageId} |
|||
</if> |
|||
group by om.id |
|||
order by om.PUBLISH_TIME desc |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,24 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.OrganizationMessagePublishRangeDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.OrganizationMessagePublishRangeEntity" id="organizationMessagePublishRangeMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="messageId" column="MESSAGE_ID"/> |
|||
<result property="orgId" column="ORG_ID"/> |
|||
<result property="orgType" column="ORG_TYPE"/> |
|||
<result property="pid" column="PID"/> |
|||
<result property="orgIdPath" column="ORG_ID_PATH"/> |
|||
<result property="orgName" column="ORG_NAME"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
|
|||
</mapper> |
Binary file not shown.
@ -0,0 +1,2 @@ |
|||
alter table resi_group add column AGENCY_ID varchar(64) comment '所属组织id' after GRID_ID; |
|||
alter table resi_group add column ORG_ID_PATH varchar(512) comment '组织idpath' after AGENCY_ID; |
@ -0,0 +1,33 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yzm |
|||
* @Date 2023/5/5 9:47 |
|||
*/ |
|||
@Data |
|||
public class RegisterRelationPageFormDTO extends PageFormDTO { |
|||
/** |
|||
* 客户Id (customer.id) |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* agencyId的所有上级,包含自己 |
|||
*/ |
|||
private String agencyIdPath; |
|||
|
|||
/** |
|||
* 网格Id (customer_grid.id) |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 首次注册用户 0表示不参与计数 1表示参与计数 |
|||
*/ |
|||
private String firstRegister; |
|||
} |
|||
|
Loading…
Reference in new issue