From 9c812a2ca93690140508a6ec7b26b37305c44e57 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 30 Jan 2023 16:44:51 +0800 Subject: [PATCH] =?UTF-8?q?certification/add-autopass=20=E7=83=9F=E5=8F=B0?= =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E8=AE=A4=E8=AF=81=E8=87=AA=E5=8A=A8=E9=80=9A?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/BadgeAuditFormDTO.java | 5 ++ .../dto/form/CertificationAddFormDTO.java | 16 +++++ .../com/epmet/controller/BadgeController.java | 3 +- .../epmet/controller/UserBadgeController.java | 22 +++++++ .../java/com/epmet/service/BadgeService.java | 3 +- .../epmet/service/impl/BadgeServiceImpl.java | 24 +++---- .../service/impl/UserBadgeServiceImpl.java | 64 ++++++++++++++++--- .../main/resources/mapper/UserBadgeDao.xml | 3 - 8 files changed, 113 insertions(+), 27 deletions(-) diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java index c3748fe49f..9803eb3c25 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java @@ -20,4 +20,9 @@ public class BadgeAuditFormDTO implements Serializable { @NotBlank(message = "审核结果不能为空") private String auditStatus; private String auditRemark; + + /** + * tokenDto.getUserId + */ + private String currentUserId; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java index da021d64f0..85ed907b4a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java @@ -65,4 +65,20 @@ public class CertificationAddFormDTO implements Serializable { */ private String code; + /** + * 是否需要发送站内信: + * 您有一条徽章认证消息,,%s申请认证%s,请审核 + * true:发送 + * false:不发送 + * 微信小程序发送 + * 烟台钉钉自动通过,默认false不发送 + */ + private Boolean sendMsgFlag; + + /** + * 自动通过标识 + * true:自动通过,目前只有烟台这么搞 + */ + private Boolean autoPassFlag; + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java index eace8b90b0..7f58178ffe 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java @@ -152,7 +152,8 @@ public class BadgeController { @NoRepeatSubmit public Result audit(@LoginUser TokenDto tokenDto, @RequestBody BadgeAuditFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); - badgeService.audit(tokenDto, formDTO); + formDTO.setCurrentUserId(tokenDto.getUserId()); + badgeService.audit(formDTO); return new Result(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java index e4ad4a63b0..4b6b4c2c56 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -1,6 +1,7 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -56,6 +57,27 @@ public class UserBadgeController { */ @PostMapping("authbadgerecord") public Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO){ + //发送微信站内信 + certificationAddFormDTO.setSendMsgFlag(true); + certificationAddFormDTO.setAutoPassFlag(false); + ValidatorUtils.validateEntity(certificationAddFormDTO, CertificationAddFormDTO.CertificationAdd.class); + return userBadgeService.authBadgeRecord(certificationAddFormDTO); + } + + /** + * 烟台钉钉居民端应用 + * + * @param tokenDto + * @param certificationAddFormDTO + * @return + */ + @NoRepeatSubmit + @PostMapping("certification/add-autopass") + public Result certificationAddAutoPass(@LoginUser TokenDto tokenDto, @RequestBody CertificationAddFormDTO certificationAddFormDTO) { + certificationAddFormDTO.setUserId(tokenDto.getUserId()); + certificationAddFormDTO.setSendMsgFlag(false); + // 是否自动通过 + certificationAddFormDTO.setAutoPassFlag(true); ValidatorUtils.validateEntity(certificationAddFormDTO, CertificationAddFormDTO.CertificationAdd.class); return userBadgeService.authBadgeRecord(certificationAddFormDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java index 34defc0541..379d3c8fad 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java @@ -169,11 +169,10 @@ public interface BadgeService extends BaseService { * 审核 * @author zhaoqifeng * @date 2020/11/5 11:08 - * @param tokenDto * @param formDTO * @return void */ - void audit(TokenDto tokenDto, BadgeAuditFormDTO formDTO); + void audit(BadgeAuditFormDTO formDTO); void testCache(); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java index 2a3809feb3..39359b29ea 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java @@ -356,32 +356,30 @@ public class BadgeServiceImpl extends BaseServiceImpl imp /** * 审核 * - * @param tokenDto token * @param formDTO 入参 * @return void * @author zhaoqifeng * @date 2020/11/5 11:08 */ @Override - public void audit(TokenDto tokenDto, BadgeAuditFormDTO formDTO) { + public void audit(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()); - BadgeDetailResultDTO detail = baseDao.selectDetail(dto.getCustomerId(), dto.getBadgeId()); dto.setAuditStatus(formDTO.getAuditStatus()); dto.setAuditRemark(formDTO.getAuditRemark()); - dto.setStaffId(tokenDto.getUserId()); + dto.setStaffId(formDTO.getCurrentUserId()); dto.setIsLast(BadgeConstant.YES); dto.setAuditTime(new Date()); userBadgeCertificateRecordService.update(dto); + BadgeDetailResultDTO detail = baseDao.selectDetail(dto.getCustomerId(), dto.getBadgeId()); List msgList = new ArrayList<>(); List wxmpMsgList = new ArrayList<>(); if(BadgeConstant.APPROVED.equals(formDTO.getAuditStatus())) { - ResiUserBadgeDTO resiUserBadgeDTO = new ResiUserBadgeDTO(); resiUserBadgeDTO.setCustomerId(dto.getCustomerId()); resiUserBadgeDTO.setBadgeId(dto.getBadgeId()); @@ -435,12 +433,16 @@ public class BadgeServiceImpl extends BaseServiceImpl imp wxmp.setGridId(dto.getGridId()); wxmpMsgList.add(wxmp); } - messageFeignClient.saveUserMessageList(msgList); - log.info("徽章消息,开始推送微信订阅消息"); - Result result = epmetMessageOpenFeignClient.sendWxSubscribeMessage(wxmpMsgList); - if (!result.success()) { - log.error("徽章消息,发送微信订阅消息失败" + JSON.toJSONString(result)); - } + if(CollectionUtils.isNotEmpty(msgList)){ + messageFeignClient.saveUserMessageList(msgList); + } + if(CollectionUtils.isNotEmpty(wxmpMsgList)){ + log.info("徽章消息,开始推送微信订阅消息"); + Result result = epmetMessageOpenFeignClient.sendWxSubscribeMessage(wxmpMsgList); + if (!result.success()) { + log.error("徽章消息,发送微信订阅消息失败" + JSON.toJSONString(result)); + } + } } @Override diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 7758ca7921..f9d07dbfc0 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -8,6 +9,7 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.BadgeConstant; @@ -24,6 +26,8 @@ import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgFeignClient; import com.epmet.redis.UserBadgeRedis; import com.epmet.redis.UserBaseInfoRedis; +import com.epmet.service.ResiUserBadgeService; +import com.epmet.service.UserBadgeCertificateRecordService; import com.epmet.service.UserBadgeService; import com.epmet.service.UserBaseInfoService; import com.epmet.util.ModuleConstant; @@ -275,7 +279,7 @@ public class UserBadgeServiceImpl implements UserBadgeService { userIds.add(certificationAddFormDTO.getUserId()); List userBaseInfoResultDTOS = userBaseInfoService.queryUserBaseInfo(userIds); if (CollectionUtils.isEmpty(userBaseInfoResultDTOS)) { - throw new RenException("查询用户基本信息集合为空......"); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),String.format("查询用户基本信息集合为空,userId:%s",certificationAddFormDTO.getUserId()),"查询用户基本信息异常"); } userBadgeDao.updateCertificateRecordIsLast(form.getBadgeId(),form.getUserId()); form.setGridId(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRegisteredGridId()); @@ -283,17 +287,57 @@ public class UserBadgeServiceImpl implements UserBadgeService { form.setCertificationImg(certificationAddFormDTO.getCertificationImg()); form.setSurname(certificationAddFormDTO.getSurname()); log.info(JSON.toJSONString(form)); + String recordId=IdWorker.getIdStr(); + form.setId(recordId); userBadgeDao.insertUserBadgeCertificateRecord(form); - //TODO 站内信发送 - String badgeName = badgeDao.selectBadgeName(form.getCustomerId(), form.getBadgeId()); - String s = StringUtils.isBlank(userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict()) ? userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName() : userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()); - String msg = String.format(BadgeConstant.MESSAGE_CONTENT, s, badgeName); - // 记录待审核id,和消息类型 - sendMessage(BadgeConstant.AUTH_TITLE,msg,form.getGridId(),form.getUserId(),form.getCustomerId(), - UserMessageTypeConstant.BADGE_AUTH_APPLY, - form.getId()); + if(certificationAddFormDTO.getSendMsgFlag()){ + //TODO 站内信发送 + String badgeName = badgeDao.selectBadgeName(form.getCustomerId(), form.getBadgeId()); + String s = StringUtils.isBlank(userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict()) ? userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName() : userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()); + String msg = String.format(BadgeConstant.MESSAGE_CONTENT, s, badgeName); + // 记录待审核id,和消息类型 + sendMessage(BadgeConstant.AUTH_TITLE,msg,form.getGridId(),form.getUserId(),form.getCustomerId(), + UserMessageTypeConstant.BADGE_AUTH_APPLY, + form.getId()); + } + //烟台:徽章认证自动审核通过 + if(certificationAddFormDTO.getAutoPassFlag()){ + BadgeAuditFormDTO badgeAuditFormDTO=new BadgeAuditFormDTO(); + badgeAuditFormDTO.setRecordId(recordId); + //审核状态 approved:审核通过,rejected:审核驳回;auditing:审核中 + badgeAuditFormDTO.setAuditStatus(BadgeConstant.APPROVED); + badgeAuditFormDTO.setCurrentUserId("APP_USER"); + autoPassBadge(badgeAuditFormDTO); + } + Map resultMap=new HashMap(); + resultMap.put("recordId",recordId); + return new Result().ok(resultMap); + } + + /** + * 烟台:徽章认证,自动审核通过 + * @param badgeAuditFormDTO + */ + private void autoPassBadge(BadgeAuditFormDTO badgeAuditFormDTO) { + UserBadgeCertificateRecordDTO dto = SpringContextUtils.getBean(UserBadgeCertificateRecordService.class).get(badgeAuditFormDTO.getRecordId()); + dto.setAuditStatus(badgeAuditFormDTO.getAuditStatus()); + dto.setAuditRemark(badgeAuditFormDTO.getAuditRemark()); + dto.setStaffId(badgeAuditFormDTO.getCurrentUserId()); + dto.setIsLast(BadgeConstant.YES); + dto.setAuditTime(new Date()); + SpringContextUtils.getBean(UserBadgeCertificateRecordService.class).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.ONE); + resiUserBadgeDTO.setCertificationAutidStatus(dto.getAuditStatus()); + SpringContextUtils.getBean(ResiUserBadgeService.class).save(resiUserBadgeDTO); + //更新Redis + userBadgeRedis.pushOrRemoveUserBadge4List(dto.getUserId(),dto.getBadgeId(),dto.getCustomerId()); - return new Result(); } private void validateParams(CertificationAddFormDTO certificationAddFormDTO, AuthFieldFormDTO authFieldFormDTO) { diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml index c42a648c62..95b77d51a7 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -171,9 +171,6 @@ - - select replace(uuid(),'-','') AS ID - INSERT INTO user_badge_certificate_record ( ID, CUSTOMER_ID,