Browse Source

徽章审核修改

master
zhaoqifeng 5 years ago
parent
commit
bd7685fb99
  1. 3
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java
  2. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java
  3. 1
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java
  4. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java
  5. 71
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java

3
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java

@ -3,6 +3,7 @@ package com.epmet.dto.form;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -14,7 +15,9 @@ import java.io.Serializable;
@Data @Data
public class BadgeAuditFormDTO implements Serializable { public class BadgeAuditFormDTO implements Serializable {
private static final long serialVersionUID = 2209535364555130964L; private static final long serialVersionUID = 2209535364555130964L;
@NotBlank(message = "申请记录Id不能为空")
private String recordId; private String recordId;
@NotBlank(message = "审核结果不能为空")
private String auditStatus; private String auditStatus;
private String auditRemark; private String auditRemark;
} }

5
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java

@ -2,6 +2,7 @@ package com.epmet.dto.form;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -12,6 +13,9 @@ import java.io.Serializable;
@Data @Data
public class BadgeFormDTO implements Serializable { public class BadgeFormDTO implements Serializable {
private static final long serialVersionUID = 9156247659994638103L; private static final long serialVersionUID = 9156247659994638103L;
public interface ManageGroup {}
public interface AuditGroup {}
@NotBlank(message = "徽章id不能为空", groups = {ManageGroup.class})
private String badgeId; private String badgeId;
/** /**
* 页码 * 页码
@ -24,5 +28,6 @@ public class BadgeFormDTO implements Serializable {
/** /**
* 网格Id * 网格Id
*/ */
@NotBlank(message = "网格id不能为空", groups = {AuditGroup.class})
private String gridId; private String gridId;
} }

1
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java

@ -16,6 +16,7 @@ import java.util.List;
@Data @Data
public class EditBadgeFormDTO implements Serializable { public class EditBadgeFormDTO implements Serializable {
private static final long serialVersionUID = 1578890423002035200L; private static final long serialVersionUID = 1578890423002035200L;
@NotBlank(message = "徽章ID不能为空")
private String badgeId; private String badgeId;
/** /**
* 徽章名称 * 徽章名称

5
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java

@ -68,6 +68,7 @@ public class BadgeController {
*/ */
@PostMapping("detail") @PostMapping("detail")
public Result<BadgeDetailResultDTO> detail(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { public Result<BadgeDetailResultDTO> detail(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, BadgeFormDTO.ManageGroup.class);
BadgeDetailResultDTO result = badgeService.detail(tokenDto, formDTO); BadgeDetailResultDTO result = badgeService.detail(tokenDto, formDTO);
return new Result<BadgeDetailResultDTO>().ok(result); return new Result<BadgeDetailResultDTO>().ok(result);
} }
@ -97,6 +98,7 @@ public class BadgeController {
*/ */
@PostMapping("delete") @PostMapping("delete")
public Result delete(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { public Result delete(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, BadgeFormDTO.ManageGroup.class);
badgeService.deleteBadge(tokenDto, formDTO); badgeService.deleteBadge(tokenDto, formDTO);
return new Result(); return new Result();
} }
@ -116,6 +118,7 @@ public class BadgeController {
*/ */
@PostMapping("auditinglist") @PostMapping("auditinglist")
public Result<List<BadgeAuditingResultDTO>> auditingList(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { public Result<List<BadgeAuditingResultDTO>> auditingList(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, BadgeFormDTO.AuditGroup.class);
List<BadgeAuditingResultDTO> result = badgeService.auditingList(tokenDto, formDTO); List<BadgeAuditingResultDTO> result = badgeService.auditingList(tokenDto, formDTO);
return new Result<List<BadgeAuditingResultDTO>>().ok(result); return new Result<List<BadgeAuditingResultDTO>>().ok(result);
} }
@ -130,6 +133,7 @@ public class BadgeController {
*/ */
@PostMapping("auditrecord") @PostMapping("auditrecord")
public Result<List<BadgeAuditRecordResultDTO>> auditRecord(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { public Result<List<BadgeAuditRecordResultDTO>> auditRecord(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, BadgeFormDTO.AuditGroup.class);
List<BadgeAuditRecordResultDTO> result = badgeService.auditRecord(tokenDto, formDTO); List<BadgeAuditRecordResultDTO> result = badgeService.auditRecord(tokenDto, formDTO);
return new Result<List<BadgeAuditRecordResultDTO>>().ok(result); return new Result<List<BadgeAuditRecordResultDTO>>().ok(result);
} }
@ -144,6 +148,7 @@ public class BadgeController {
*/ */
@PostMapping("audit") @PostMapping("audit")
public Result audit(@LoginUser TokenDto tokenDto, @RequestBody BadgeAuditFormDTO formDTO) { public Result audit(@LoginUser TokenDto tokenDto, @RequestBody BadgeAuditFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
badgeService.audit(tokenDto, formDTO); badgeService.audit(tokenDto, formDTO);
return new Result(); return new Result();
} }

71
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -25,9 +26,11 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.exception.ValidateException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.BadgeConstant; import com.epmet.constant.BadgeConstant;
import com.epmet.constant.BadgeMessageConstant; import com.epmet.constant.BadgeMessageConstant;
import com.epmet.constant.UserConstant; import com.epmet.constant.UserConstant;
@ -42,9 +45,11 @@ import com.epmet.dto.result.BadgeDetailResultDTO;
import com.epmet.dto.result.BadgeListResultDTO; import com.epmet.dto.result.BadgeListResultDTO;
import com.epmet.entity.BadgeCertificationConfigEntity; import com.epmet.entity.BadgeCertificationConfigEntity;
import com.epmet.entity.BadgeEntity; import com.epmet.entity.BadgeEntity;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.MessageFeignClient; import com.epmet.feign.MessageFeignClient;
import com.epmet.redis.UserBadgeRedis; import com.epmet.redis.UserBadgeRedis;
import com.epmet.service.*; import com.epmet.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -60,6 +65,7 @@ import java.util.*;
* @since v1.0.0 2020-11-03 * @since v1.0.0 2020-11-03
*/ */
@Service @Service
@Slf4j
public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> implements BadgeService { public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> implements BadgeService {
@Autowired @Autowired
@ -74,6 +80,9 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
private ResiUserBadgeService resiUserBadgeService; private ResiUserBadgeService resiUserBadgeService;
@Autowired @Autowired
private MessageFeignClient messageFeignClient; private MessageFeignClient messageFeignClient;
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Override @Override
@ -322,6 +331,11 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
*/ */
@Override @Override
public void audit(TokenDto tokenDto, BadgeAuditFormDTO formDTO) { public void audit(TokenDto tokenDto, BadgeAuditFormDTO formDTO) {
if(BadgeConstant.REJECTED.equals(formDTO.getAuditStatus())) {
if (StringUtils.isEmpty(formDTO.getAuditRemark())) {
throw new ValidateException(EpmetErrorCode.CUSTOMER_VALIDATE_ERROR.getCode(), "驳回理由不能为空");
}
}
UserBadgeCertificateRecordDTO dto = userBadgeCertificateRecordService.get(formDTO.getRecordId()); UserBadgeCertificateRecordDTO dto = userBadgeCertificateRecordService.get(formDTO.getRecordId());
BadgeDetailResultDTO detail = baseDao.selectDetail(dto.getCustomerId(), dto.getBadgeId()); BadgeDetailResultDTO detail = baseDao.selectDetail(dto.getCustomerId(), dto.getBadgeId());
dto.setAuditStatus(formDTO.getAuditStatus()); dto.setAuditStatus(formDTO.getAuditStatus());
@ -329,48 +343,71 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
dto.setStaffId(tokenDto.getUserId()); dto.setStaffId(tokenDto.getUserId());
dto.setIsLast(BadgeConstant.YES); dto.setIsLast(BadgeConstant.YES);
dto.setAuditTime(new Date()); dto.setAuditTime(new Date());
userBadgeCertificateRecordService.update(dto); userBadgeCertificateRecordService.update(dto);
ResiUserBadgeDTO resiUserBadgeDTO = new ResiUserBadgeDTO();
resiUserBadgeDTO.setCustomerId(dto.getCustomerId());
resiUserBadgeDTO.setBadgeId(dto.getBadgeId());
resiUserBadgeDTO.setGridId(dto.getGridId());
resiUserBadgeDTO.setUserId(dto.getUserId());
resiUserBadgeDTO.setIsOpened(NumConstant.ZERO);
resiUserBadgeDTO.setCertificationAutidStatus(dto.getAuditStatus());
resiUserBadgeService.save(resiUserBadgeDTO);
List<UserMessageFormDTO> msgList = new ArrayList<>(); List<UserMessageFormDTO> msgList = new ArrayList<>();
List<WxSubscribeMessageFormDTO> wxmpMsgList = new ArrayList<>();
if(BadgeConstant.APPROVED.equals(formDTO.getAuditStatus())) { if(BadgeConstant.APPROVED.equals(formDTO.getAuditStatus())) {
ResiUserBadgeDTO resiUserBadgeDTO = new ResiUserBadgeDTO();
resiUserBadgeDTO.setCustomerId(dto.getCustomerId());
resiUserBadgeDTO.setBadgeId(dto.getBadgeId());
resiUserBadgeDTO.setGridId(dto.getGridId());
resiUserBadgeDTO.setUserId(dto.getUserId());
resiUserBadgeDTO.setIsOpened(NumConstant.ONE);
resiUserBadgeDTO.setCertificationAutidStatus(dto.getAuditStatus());
resiUserBadgeService.save(resiUserBadgeDTO);
//更新Redis //更新Redis
OpenedOrClosedFormDTO openedOrClosedFormDTO = new OpenedOrClosedFormDTO(); badgeRedis.pushOrRemoveUserBadge4List(dto.getUserId(),dto.getBadgeId(),dto.getCustomerId());
openedOrClosedFormDTO.setCustomerId(dto.getCustomerId());
openedOrClosedFormDTO.setUserId(dto.getUserId());
openedOrClosedFormDTO.setBadgeId(dto.getBadgeId());
userBadgeService.openedOrClosed(openedOrClosedFormDTO);
//通知 //通知
String msg = String.format(BadgeMessageConstant.APPROVED_MSG, detail.getBadgeName());
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); UserMessageFormDTO messageFormDTO = new UserMessageFormDTO();
messageFormDTO.setCustomerId(dto.getCustomerId()); messageFormDTO.setCustomerId(dto.getCustomerId());
messageFormDTO.setApp(UserConstant.APP_RESI); messageFormDTO.setApp(UserConstant.APP_RESI);
messageFormDTO.setGridId(dto.getGridId()); messageFormDTO.setGridId(dto.getGridId());
messageFormDTO.setUserId(dto.getUserId()); messageFormDTO.setUserId(dto.getUserId());
messageFormDTO.setTitle(BadgeMessageConstant.TITLE); messageFormDTO.setTitle(BadgeMessageConstant.TITLE);
messageFormDTO.setMessageContent(String.format(BadgeMessageConstant.APPROVED_MSG, detail.getBadgeName())); messageFormDTO.setMessageContent(msg);
messageFormDTO.setReadFlag(Constant.UNREAD); messageFormDTO.setReadFlag(Constant.UNREAD);
//微信消息
WxSubscribeMessageFormDTO wxmp = new WxSubscribeMessageFormDTO();
wxmp.setCustomerId(dto.getCustomerId());
wxmp.setClientType(UserConstant.APP_RESI);
wxmp.setUserId(dto.getUserId());
wxmp.setBehaviorType("徽章消息");
wxmp.setMessageContent(msg);
wxmp.setMessageTime(new Date());
wxmp.setGridId(dto.getGridId());
wxmpMsgList.add(wxmp);
} else { } else {
//通知 //通知
String msg = String.format(BadgeMessageConstant.REJECTED_MSG, detail.getBadgeName(), formDTO.getAuditRemark());
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); UserMessageFormDTO messageFormDTO = new UserMessageFormDTO();
messageFormDTO.setCustomerId(dto.getCustomerId()); messageFormDTO.setCustomerId(dto.getCustomerId());
messageFormDTO.setApp(UserConstant.APP_RESI); messageFormDTO.setApp(UserConstant.APP_RESI);
messageFormDTO.setGridId(dto.getGridId()); messageFormDTO.setGridId(dto.getGridId());
messageFormDTO.setUserId(dto.getUserId()); messageFormDTO.setUserId(dto.getUserId());
messageFormDTO.setTitle(BadgeMessageConstant.TITLE); messageFormDTO.setTitle(BadgeMessageConstant.TITLE);
messageFormDTO.setMessageContent(String.format(BadgeMessageConstant.REJECTED_MSG, detail.getBadgeName(), formDTO.getAuditRemark())); messageFormDTO.setMessageContent(msg);
messageFormDTO.setReadFlag(Constant.UNREAD); messageFormDTO.setReadFlag(Constant.UNREAD);
msgList.add(messageFormDTO); msgList.add(messageFormDTO);
//微信消息
WxSubscribeMessageFormDTO wxmp = new WxSubscribeMessageFormDTO();
wxmp.setCustomerId(dto.getCustomerId());
wxmp.setClientType(UserConstant.APP_RESI);
wxmp.setUserId(dto.getUserId());
wxmp.setBehaviorType("徽章消息");
wxmp.setMessageContent(msg);
wxmp.setMessageTime(new Date());
wxmp.setGridId(dto.getGridId());
wxmpMsgList.add(wxmp);
} }
messageFeignClient.saveUserMessageList(msgList); messageFeignClient.saveUserMessageList(msgList);
log.info("徽章消息,开始推送微信订阅消息");
Result result = epmetMessageOpenFeignClient.sendWxSubscribeMessage(wxmpMsgList);
if (!result.success()) {
log.error("徽章消息,发送微信订阅消息失败" + JSON.toJSONString(result));
}
} }
@Override @Override

Loading…
Cancel
Save