Browse Source

防疫通知

dev
zhaoqifeng 3 years ago
parent
commit
1bdfbf6acd
  1. 57
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java
  2. 12
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java
  3. 21
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java
  4. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java
  5. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java
  6. 36
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java

57
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java

@ -0,0 +1,57 @@
package com.epmet.commons.tools.enums;
import com.epmet.commons.tools.exception.EpmetErrorCode;
/**
* @author Administrator
*/
public enum ChannelEnum {
//通知渠道 0小程序通知,1短信通知
APP("0", "小程序通知"),
MESSAGE("1", "短信通知"),
ALL("2", "小程序通知,短信通知");
private String code;
private String name;
ChannelEnum(String code, String name) {
this.code = code;
this.name = name;
}
public static String getName(String code) {
ChannelEnum[] houseTypeEnums = values();
for (ChannelEnum houseTypeEnum : houseTypeEnums) {
if (houseTypeEnum.getCode() == code) {
return houseTypeEnum.getName();
}
}
return EpmetErrorCode.SERVER_ERROR.getMsg();
}
public static String getCode(String name) {
ChannelEnum[] houseTypeEnums = values();
for (ChannelEnum houseTypeEnum : houseTypeEnums) {
if (houseTypeEnum.getName().equals(name)) {
return houseTypeEnum.getCode();
}
}
return null;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

12
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java

@ -1,6 +1,7 @@
package com.epmet.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
@ -22,11 +23,13 @@ public class IcNoticeDTO implements Serializable {
/**
* 唯一标识
*/
@JsonIgnore
private String id;
/**
* 客户Id customer.id
*/
@JsonIgnore
private String customerId;
/**
@ -37,20 +40,24 @@ public class IcNoticeDTO implements Serializable {
/**
* 通知来源 0行程上报1疫苗接种2核酸检测
*/
@JsonIgnore
private String origin;
/**
* 用户ID
*/
@JsonIgnore
private String userId;
/**
* 手机号
*/
@JsonIgnore
private String mobile;
/**
* 被通知人身份证号
*/
@JsonIgnore
private String idCard;
/**
@ -66,16 +73,19 @@ public class IcNoticeDTO implements Serializable {
/**
* 删除标识0.未删除 1.已删除
*/
@JsonIgnore
private Integer delFlag;
/**
* 乐观锁
*/
@JsonIgnore
private Integer revision;
/**
* 创建人
*/
@JsonIgnore
private String createdBy;
/**
@ -87,11 +97,13 @@ public class IcNoticeDTO implements Serializable {
/**
* 更新人
*/
@JsonIgnore
private String updatedBy;
/**
* 更新时间
*/
@JsonIgnore
private Date updatedTime;
}

21
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description
* @Author zhaoqifeng
* @Date 2022/3/28 16:13
*/
@Data
public class IcNoticeFormDTO extends PageFormDTO implements Serializable {
private static final long serialVersionUID = 7392894573654015338L;
private String customerId;
@NotBlank(message = "身份证号不能为空", groups = DefaultGroup.class)
private String idCard;
}

8
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java

@ -11,13 +11,12 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.IcNoticeDTO;
import com.epmet.dto.form.IcNoticeFormDTO;
import com.epmet.dto.form.SendNoticeFormDTO;
import com.epmet.service.IcNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 防疫通知
@ -33,8 +32,9 @@ public class IcNoticeController {
private IcNoticeService icNoticeService;
@RequestMapping("page")
public Result<PageData<IcNoticeDTO>> page(@RequestParam Map<String, Object> params){
PageData<IcNoticeDTO> page = icNoticeService.page(params);
public Result<PageData<IcNoticeDTO>> page(@LoginUser TokenDto tokenDto, @RequestBody IcNoticeFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
PageData<IcNoticeDTO> page = icNoticeService.page(formDTO);
return new Result<PageData<IcNoticeDTO>>().ok(page);
}

5
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java

@ -3,6 +3,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IcNoticeDTO;
import com.epmet.dto.form.IcNoticeFormDTO;
import com.epmet.dto.form.SendNoticeFormDTO;
import com.epmet.entity.IcNoticeEntity;
@ -20,12 +21,12 @@ public interface IcNoticeService extends BaseService<IcNoticeEntity> {
/**
* 默认分页
*
* @param params
* @param dto
* @return PageData<IcNoticeDTO>
* @author generator
* @date 2022-03-28
*/
PageData<IcNoticeDTO> page(Map<String, Object> params);
PageData<IcNoticeDTO> page(IcNoticeFormDTO formDTO);
/**
* 默认查询

36
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java

@ -3,9 +3,9 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.*;
import com.epmet.commons.tools.enums.ChannelEnum;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
@ -13,12 +13,15 @@ import com.epmet.constant.SmsTemplateConstant;
import com.epmet.constant.UserMessageTypeConstant;
import com.epmet.dao.IcNoticeDao;
import com.epmet.dto.IcNoticeDTO;
import com.epmet.dto.form.IcNoticeFormDTO;
import com.epmet.dto.form.ProjectSendMsgFormDTO;
import com.epmet.dto.form.SendNoticeFormDTO;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.entity.IcNoticeEntity;
import com.epmet.feign.MessageFeignClient;
import com.epmet.service.IcNoticeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -46,12 +49,27 @@ public class IcNoticeServiceImpl extends BaseServiceImpl<IcNoticeDao, IcNoticeEn
private MessageFeignClient messageFeignClient;
@Override
public PageData<IcNoticeDTO> page(Map<String, Object> params) {
IPage<IcNoticeEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, IcNoticeDTO.class);
public PageData<IcNoticeDTO> page(IcNoticeFormDTO formDTO) {
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
LambdaQueryWrapper<IcNoticeEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcNoticeEntity::getCustomerId, formDTO.getCustomerId());
wrapper.eq(IcNoticeEntity::getIdCard, formDTO.getIdCard());
wrapper.orderByDesc(IcNoticeEntity::getCreatedTime);
List<IcNoticeEntity> list = baseDao.selectList(wrapper);
PageInfo<IcNoticeEntity> pageInfo = new PageInfo<>(list);
List<IcNoticeDTO> dtoList = ConvertUtils.sourceToTarget(list, IcNoticeDTO.class);
if (CollectionUtils.isNotEmpty(dtoList)) {
dtoList.forEach(item -> {
List<String> channelList = Arrays.asList(item.getChannel().split(StrConstant.COMMA));
if (channelList.size() == NumConstant.ONE) {
item.setChannel(ChannelEnum.getName(channelList.get(0)));
} else {
item.setChannel(ChannelEnum.getName(NumConstant.TWO_STR));
}
});
}
return new PageData<>(dtoList, pageInfo.getTotal());
}
@Override
@ -115,9 +133,9 @@ public class IcNoticeServiceImpl extends BaseServiceImpl<IcNoticeDao, IcNoticeEn
entity.setCustomerId(formDTO.getCustomerId());
entity.setChannel(channel);
entity.setContent(formDTO.getContent());
entity.setOrigin(entity.getOrigin());
entity.setOrigin(formDTO.getOrigin());
entity.setUserId(item.getUserId());
entity.setMobile(entity.getMobile());
entity.setMobile(item.getMobile());
entity.setIdCard(item.getIdCard());
entity.setOrgName(formDTO.getOrgName());
return entity;

Loading…
Cancel
Save