diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonAggFeignClient.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonAggFeignClient.java index cb7146138d..2d8d021805 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonAggFeignClient.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonAggFeignClient.java @@ -39,15 +39,6 @@ public interface CommonAggFeignClient { @PostMapping("/data/aggregator/org/agency") Result getAgencyInfo(@RequestParam("agencyId")String agencyId); - /** - * @Description 查询网格信息 - * @param gridId - * @author zxc - * @date 2021/11/5 2:54 下午 - */ - @PostMapping("/data/aggregator/org/grid") - Result getGridInfo(@RequestParam("gridId")String gridId); - /** * 查询楼栋信息 * @param buildingId diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonAggFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonAggFeignClientFallback.java index 8d6f5f1260..50e4cf32c9 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonAggFeignClientFallback.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonAggFeignClientFallback.java @@ -29,11 +29,6 @@ public class CommonAggFeignClientFallback implements CommonAggFeignClient { return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "getAgencyInfo", agencyId); } - @Override - public Result getGridInfo(String gridId) { - return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "getGridInfo", gridId); - } - /** * 查询楼栋信息 * diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index b29dfbcdac..8190c9418d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -157,11 +157,20 @@ public interface EpmetUserFeignClient { Result getCustomerStaffList(List staffIdList); /** - * desc:删除审核中的徽章认证记录 + * desc:删除审核中的徽章认证记录-弃用网格是调用 * @param customerId * @param gridId * @return */ @PostMapping("/epmetuser/badge/deleteBadgeCertificateAuditing") Result deleteBadgeCertificateAuditing(@RequestParam("customerId") String customerId, @RequestParam("gridId") String gridId); + + /** + * desc:删除弃用网格的访问记录-弃用网格是调用 + * @param customerId + * @param gridId + * @return + */ + @PostMapping("/epmetuser/gridlatest/deleteGridLatestData") + Result deleteGridLatestData(@RequestParam("customerId") String customerId, @RequestParam("gridId") String gridId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index 70bc8b7892..4594d36a60 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -96,4 +96,9 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { public Result deleteBadgeCertificateAuditing(String customerId, String gridId) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "deleteBadgeCertificateAuditing", customerId, gridId); } + + @Override + public Result deleteGridLatestData(String customerId, String gridId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "deleteGridLatestData", customerId, gridId); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index c337f989e3..70945c6fe1 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -1046,7 +1046,11 @@ public class CustomerGridServiceImpl extends BaseServiceImpl gridLatestResult = epmetUserFeignClient.deleteGridLatestData(customerId,gridId); + if (gridLatestResult == null || !gridLatestResult.success()){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"删除网格访问记录失败,请稍后重试"); + } //处理成功,隐藏网格 LambdaUpdateWrapper updateGrid=new LambdaUpdateWrapper<>(); updateGrid.set(CustomerGridEntity::getAbandonFlag,NumConstant.ONE); diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index 426b4fbb0a..c3390d9cc9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -342,7 +342,6 @@ WHERE cg.del_flag = '0' AND ca.del_flag = '0' AND cg.SYNC_FLAG='1' - and cg.ABANDON_FLAG='0' AND cg.id IN #{id} 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 37c56eeac9..eace8b90b0 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 @@ -1,7 +1,9 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.enums.RequirePermissionEnum; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -218,11 +220,12 @@ public class BadgeController { } /** - * Desc: 查询网格下是否存在未审核的徽章,true:是,false:否 + * desc:删除审核中的徽章认证记录-弃用网格是调用 + * @param customerId * @param gridId - * @author zxc - * @date 2022/3/16 9:42 上午 + * @return */ + @RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_DELETE) @PostMapping("deleteBadgeCertificateAuditing") public Result deleteBadgeCertificateAuditing(@RequestParam("customerId") String customerId,@RequestParam("gridId")String gridId){ return new Result().ok(badgeService.deleteBadgeCertificateAuditing(customerId,gridId)); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java index c470d793a9..b1b07c4e9e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridLatestController.java @@ -143,4 +143,15 @@ public class GridLatestController { return new Result().ok(gridLatestService.latestGridInfo(formDTO)); } + /** + * desc:删除弃用网格的访问记录-弃用网格是调用 + * @param customerId + * @param gridId + * @return + */ + @PostMapping("deleteGridLatestData") + public Result deleteGridLatestData(@RequestParam("customerId") String customerId,@RequestParam("gridId")String gridId){ + return new Result().ok(gridLatestService.deleteGridLatestData(customerId,gridId)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserRegGridChangeRecDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserRegGridChangeRecDao.java new file mode 100644 index 0000000000..c14ace1ab7 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserRegGridChangeRecDao.java @@ -0,0 +1,16 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.UserRegGridChangeRecEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 用户注册网格变更记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-03-17 + */ +@Mapper +public interface UserRegGridChangeRecDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserRegGridChangeRecEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserRegGridChangeRecEntity.java new file mode 100644 index 0000000000..262c79e608 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserRegGridChangeRecEntity.java @@ -0,0 +1,41 @@ +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 2022-03-17 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("user_reg_grid_change_rec") +public class UserRegGridChangeRecEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 居民端用户id + */ + private String userId; + + /** + * 原始网格id + */ + private String originGridId; + + /** + * 当前所选择的注册网格 + */ + private String gridId; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java index e9ff239d1e..2ba30ae954 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java @@ -140,4 +140,12 @@ public interface GridLatestService extends BaseService { * @Date 2020/8/3 **/ LatestGridInfoResultDTO latestGridInfo(LatestGridInfoFormDTO formDTO); + + /** + * desc:删除弃用网格的访问记录-弃用网格是调用 + * @param customerId + * @param gridId + * @return + */ + Integer deleteGridLatestData(String customerId, String gridId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java index 58f9383078..fabf993292 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java @@ -19,6 +19,7 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; @@ -36,7 +37,6 @@ import com.epmet.dto.result.CustomerUser4PointResultDTO; import com.epmet.dto.result.LatestGridInfoResultDTO; import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.entity.GridLatestEntity; -import com.epmet.feign.EpmetHeartOpenFeignClient; import com.epmet.redis.UserBaseInfoRedis; import com.epmet.service.GridLatestService; import com.epmet.util.ModuleConstant; @@ -210,4 +210,13 @@ public class GridLatestServiceImpl extends BaseServiceImpl wrapper = new LambdaUpdateWrapper(); + wrapper.eq(GridLatestEntity::getCustomerId,customerId) + .eq(GridLatestEntity::getGridId,gridId) + .set(GridLatestEntity::getUpdatedTime,System.currentTimeMillis()); + return baseDao.delete(wrapper); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java index a6f88e5c0f..12380e64c2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java @@ -75,6 +75,9 @@ public class UserServiceImpl extends BaseServiceImpl implem private UserBadgeCertificateRecordDao userBadgeCertificateRecordDao; @Autowired private UserBaseInfoRedis userBaseInfoRedis; + @Autowired + private UserRegGridChangeRecDao UserRegGridChangeRecDao; + private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class); @@ -438,8 +441,9 @@ public class UserServiceImpl extends BaseServiceImpl implem @Override public void modifyRegGrid(ModifyRegGridFormDTO formDTO) { GridInfoCache newGridInfo= CustomerOrgRedis.getGridInfo(formDTO.getGridId()); - if (null == newGridInfo) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:查询当前网格信息异常", "服务器开小差了..."); + RegisterRelationEntity originReg=registerRelationDao.selectRegisteredGridIdByUserIdAndCustomerId(formDTO.getUserId(),formDTO.getCustomerId()); + if (null == newGridInfo || null == originReg) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:查询网格信息异常", "服务器开小差了..."); } //修改register_relation表 LambdaQueryWrapper originWrapper=new LambdaQueryWrapper(); @@ -467,18 +471,36 @@ public class UserServiceImpl extends BaseServiceImpl implem //2、修改历史徽章表 LambdaUpdateWrapper recUpdate=new LambdaUpdateWrapper<>(); - recUpdate.set(UserBadgeCertificateRecordEntity::getGridId,newGridInfo.getId()); + recUpdate.set(UserBadgeCertificateRecordEntity::getGridId,newGridInfo.getId()) + .set(UserBadgeCertificateRecordEntity::getUpdatedBy,formDTO.getUserId()) + .set(UserBadgeCertificateRecordEntity::getUpdatedTime,new Date()); recUpdate.eq(UserBadgeCertificateRecordEntity::getCustomerId,formDTO.getCustomerId()) .eq(UserBadgeCertificateRecordEntity::getUserId,formDTO.getUserId()); userBadgeCertificateRecordDao.update(null,recUpdate); LambdaUpdateWrapper badgeUpdate=new LambdaUpdateWrapper<>(); - badgeUpdate.set(ResiUserBadgeEntity::getGridId,newGridInfo.getId()); + badgeUpdate.set(ResiUserBadgeEntity::getGridId,newGridInfo.getId()) + .set(ResiUserBadgeEntity::getUpdatedBy,formDTO.getUserId()) + .set(ResiUserBadgeEntity::getUpdatedTime,new Date());; badgeUpdate.eq(ResiUserBadgeEntity::getCustomerId,formDTO.getCustomerId()) .eq(ResiUserBadgeEntity::getUserId,formDTO.getUserId()); resiUserBadgeDao.update(null,badgeUpdate); //3、修改支援者信息表 + modifyVolunteerGrid(formDTO,newGridInfo); + + //4、删除用户缓存信息 + userBaseInfoRedis.clearUserCache(Arrays.asList(formDTO.getUserId())); + //5、插入用户注册网格变更记录 + UserRegGridChangeRecEntity log=new UserRegGridChangeRecEntity(); + log.setCustomerId(formDTO.getCustomerId()); + log.setUserId(formDTO.getUserId()); + log.setOriginGridId(originReg.getGridId()); + log.setGridId(formDTO.getGridId()); + UserRegGridChangeRecDao.insert(log); + } + + private void modifyVolunteerGrid(ModifyRegGridFormDTO formDTO, GridInfoCache newGridInfo) { VolunteerInfoDTO volunteerInfoDTO=new VolunteerInfoDTO(); volunteerInfoDTO.setCustomerId(formDTO.getCustomerId()); volunteerInfoDTO.setUserId(formDTO.getUserId()); @@ -490,8 +512,6 @@ public class UserServiceImpl extends BaseServiceImpl implem if (!volunteerRes.success()) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:修改用户志愿者信息异常", "服务器开小差了..."); } - //4、删除用户缓存信息 - userBaseInfoRedis.clearUserCache(Arrays.asList(formDTO.getUserId())); } } diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.25__create_user_reg_grid_rec.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.25__create_user_reg_grid_rec.sql new file mode 100644 index 0000000000..85a0db8e18 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.25__create_user_reg_grid_rec.sql @@ -0,0 +1,14 @@ +CREATE TABLE `user_reg_grid_change_rec` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `USER_ID` varchar(64) NOT NULL COMMENT '居民端用户id', + `ORIGIN_GRID_ID` varchar(64) NOT NULL COMMENT '原始网格id', + `GRID_ID` varchar(64) NOT NULL COMMENT '当前所选择的注册网格', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 1删除;0未删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户注册网格变更记录表'; \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml index 74c1691615..3ce51f018a 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml @@ -79,7 +79,7 @@ diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserRegGridChangeRecDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserRegGridChangeRecDao.xml new file mode 100644 index 0000000000..4fcd5c664e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserRegGridChangeRecDao.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file