From e8619eb9dad990c639b03894cb2df6d8ba7803b3 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 16 Mar 2022 14:52:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=83=E7=94=A8=E7=BD=91=E6=A0=BC=20?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86(?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=85=B3=E7=B3=BB=E5=92=8C=E5=BE=BD=E7=AB=A0?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/GridController.java | 12 ++++ .../java/com/epmet/dao/CustomerGridDao.java | 12 +++- .../com/epmet/dao/CustomerStaffGridDao.java | 14 ++-- .../EpmetUserFeignClientFallBack.java | 20 ++---- .../epmet/service/CustomerGridService.java | 6 ++ .../java/com/epmet/service/StaffService.java | 2 +- .../service/impl/CustomerGridServiceImpl.java | 66 ++++++++++++++++++- .../main/resources/mapper/CustomerGridDao.xml | 4 ++ .../resources/mapper/CustomerStaffGridDao.xml | 16 ++++- .../com/epmet/controller/BadgeController.java | 12 +++- .../java/com/epmet/service/BadgeService.java | 9 ++- .../UserBadgeCertificateRecordService.java | 10 ++- .../epmet/service/impl/BadgeServiceImpl.java | 8 ++- ...UserBadgeCertificateRecordServiceImpl.java | 12 +++- 14 files changed, 173 insertions(+), 30 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java index 60ffda8b94..1bfe447675 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java @@ -239,4 +239,16 @@ public class GridController { customerGridService.abandonGrid(formDTO); return new Result(); } + + /** + * desc:移除网格内的工作人员关系 并迁移到组织 + * @author jianjun liu + * @remark: 如果是网格添加的则解除关系后将注册关系改为对应的组织 如果不是则直接解除关系(相当于移除该人员与网格的关系) + */ + @PostMapping("removeGridStaff2Agency/{gridId}") + //@RequirePermission(requirePermission = RequirePermissionEnum.ORG_STAFF_TRANSFER) + public Result removeGridStaff2Agency( @PathVariable String gridId){ + customerGridService.abandonGridForDealBizData(gridId); + return new Result(); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 3dcedd5c73..d642c4a911 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -367,11 +367,19 @@ public interface CustomerGridDao extends BaseDao { List getStaffGridList(@Param("customerId") String customerId, @Param("orgId") String orgId, @Param("orgType") String orgType); /** - * @Description 根据网格名字查询网格信息 * @param names + * @Description 根据网格名字查询网格信息 * @author zxc * @date 2022/2/12 2:06 下午 */ - List selectGridInfoByNames(@Param("names")List names,@Param("customerId")String customerId); + List selectGridInfoByNames(@Param("names") List names, @Param("customerId") String customerId); + /** + * desc:修改网格工作人员数量 + * + * @param gridId + * @param incrCount 增加人数 负数为 - + * @return + */ + int updateTotalUser(@Param("gridId") String gridId, @Param("incrCount") long incrCount); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java index 426a0e6b3a..238e8e9c16 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerStaffGridDao.java @@ -19,8 +19,8 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.CustomerStaffDepartmentDTO; import com.epmet.dto.CustomerStaffGridDTO; +import com.epmet.dto.StaffOrgRelationDTO; import com.epmet.dto.form.LatestGridFormDTO; import com.epmet.dto.result.EventTitleOrgResultDTO; import com.epmet.dto.result.GridStaffResultDTO; @@ -28,12 +28,11 @@ import com.epmet.entity.CustomerStaffGridEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.util.HashSet; import java.util.List; import java.util.Set; /** - * 网格人员关系表 + * 网格人员关系表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-04-20 @@ -115,4 +114,11 @@ public interface CustomerStaffGridDao extends BaseDao { * @date 2021/8/5 5:36 下午 */ List eventOrg(@Param("userId") String userId); -} \ No newline at end of file + + /** + * desc:根据网格id 获取网格下的工作人员及其添加关系 + * @param gridId + * @return + */ + List getGridStaffList(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 f6ac8153ce..8aa28ad9f7 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 @@ -4,23 +4,8 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.*; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; -import com.epmet.dto.form.AddDepartmentStaffFormDTO; -import com.epmet.dto.form.DepartmentInStaffFormDTO; -import com.epmet.dto.form.StaffInfoFromDTO; -import com.epmet.dto.form.StaffSubmitFromDTO; -import com.epmet.dto.form.StaffsInAgencyFromDTO; -import com.epmet.dto.result.DepartInStaffListResultDTO; -import com.epmet.dto.result.StaffDetailResultDTO; -import com.epmet.dto.result.StaffInfoResultDTO; -import com.epmet.dto.result.StaffInitResultDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.dto.CustomerStaffDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.StaffGridListDTO; import com.epmet.feign.EpmetUserFeignClient; import org.springframework.stereotype.Component; @@ -106,4 +91,9 @@ public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { public Result getCustomerStaffList(List staffIdList) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffList", staffIdList); } + + @Override + public Result updateUserBadgeCertificateRecord(String customerId, String gridId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "updateUserBadgeCertificateRecord", customerId, gridId); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java index c57c5052ed..504555fbc7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java @@ -381,4 +381,10 @@ public interface CustomerGridService extends BaseService { * @return */ void abandonGrid(AbandonGridFormDTO formDTO); + + /** + * desc:移除网格内的工作人员关系 并迁移到组织 + * @param gridId + */ + void abandonGridForDealBizData(String gridId); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java index ccd998c0fc..2c11cd6444 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/StaffService.java @@ -89,7 +89,7 @@ public interface StaffService { * @return com.epmet.dto.result.MineResultDTO */ MineResultDTO mine(StaffInfoFromDTO fromDTO); - + /** * 工作人员调动 * @author zhaoqifeng 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 2f5436c710..962dcd994e 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 @@ -18,6 +18,7 @@ package com.epmet.service.impl; import cn.hutool.core.bean.BeanUtil; +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.conditions.update.LambdaUpdateWrapper; @@ -28,12 +29,14 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.enums.DictTypeEnum; +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.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; @@ -41,10 +44,13 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerGridConstant; import com.epmet.dao.CustomerGridDao; import com.epmet.dao.CustomerStaffGridDao; +import com.epmet.dao.StaffOrgRelationDao; import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerGridEntity; +import com.epmet.entity.CustomerStaffGridEntity; +import com.epmet.entity.StaffOrgRelationEntity; import com.epmet.feign.*; import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; import com.epmet.service.CustomerAgencyService; @@ -86,6 +92,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl updateGrid=new LambdaUpdateWrapper<>(); @@ -992,4 +1000,60 @@ public class CustomerGridServiceImpl extends BaseServiceImpl staffList = customerStaffGridDao.getGridStaffList(gridId); + if (CollectionUtils.isEmpty(staffList)){ + log.info("abandonGridForDealBizData gridId:{} have any staff", gridId); + return; + } + logger.debug("abandonGridForDealBizData staffList:{}", JSON.toJSONString(staffList)); + List updateList = new ArrayList<>(); + staffList.forEach(staffOrg->{ + if(OrgTypeEnum.GRID.getCode().equals(staffOrg.getOrgType())){ + StaffOrgRelationEntity entity = new StaffOrgRelationEntity(); + entity.setId(staffOrg.getId()); + entity.setOrgType(OrgTypeEnum.AGENCY.getCode()); + String pid = CustomerOrgRedis.getGridInfo(staffOrg.getStaffId()).getPid(); + if (StringUtils.isBlank(pid)){ + log.error("abandonGridForDealBizData agencyId:{} is not exist",pid); + return; + } + entity.setOrgId(pid); + updateList.add(entity); + } + }); + //更新工作人员组织关系 + String customerId = staffList.get(NumConstant.ZERO).getCustomerId(); + updateGridStaff2Agency(customerId,gridId, staffList, updateList); + //清空工作人员缓存 + staffList.forEach(staff->CustomerStaffRedis.delStaffInfoFormCache(customerId,staff.getStaffId())); + } catch (Exception e) { + log.error("abandonGridForDealBizData exception", e); + throw e; + } + + } + @Transactional + public void updateGridStaff2Agency(String customerId, String gridId, List staffList, List updateList) { + //1.删除工作人员与网格的关系 + LambdaQueryWrapper updateWrapper = new LambdaQueryWrapper<>(); + updateWrapper.eq(CustomerStaffGridEntity::getGridId,gridId); + customerStaffGridDao.delete(updateWrapper); + //2.修改 网格内添加工作人员改为组织 + updateList.forEach(e->{ + staffOrgRelationDao.update(e,null); + }); + //网格对应的人数减少 + long reduceCount = NumConstant.ZERO - staffList.stream().map(StaffOrgRelationDTO::getStaffId).distinct().count(); + log.debug("updateGridStaff2Agency gridId:{} reduceCount:{}",gridId, reduceCount); + int effectRow = customerGridDao.updateTotalUser(gridId, reduceCount); + Result badgeResult = epmetUserFeignClient.deleteBadgeCertificateAuditing(customerId,gridId); + if (badgeResult == null || !badgeResult.success()){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"删除未审核徽章失败,请稍后重试"); + } + } + } 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 e805ace544..4690b1f384 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 @@ -844,5 +844,9 @@ ) + + UPDATE customer_grid SET total_user = total_user+#{incrCount} + where id = #{gridId} and del_flag = '0' + diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml index 1d11a957b2..cf57cc708f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffGridDao.xml @@ -173,4 +173,18 @@ AND DEL_FLAG = 0 - \ No newline at end of file + + 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 7c02a9df9d..700c7b56bf 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 @@ -12,7 +12,6 @@ import com.epmet.service.BadgeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import javax.validation.constraints.NotBlank; import java.util.List; import java.util.Map; @@ -218,4 +217,15 @@ public class BadgeController { return new Result().ok(badgeService.badgeAuditReset(gridId)); } + /** + * Desc: 查询网格下是否存在未审核的徽章,true:是,false:否 + * @param gridId + * @author zxc + * @date 2022/3/16 9:42 上午 + */ + @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/service/BadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java index 4b2252b51c..34defc0541 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 @@ -209,4 +209,11 @@ public interface BadgeService extends BaseService { */ Boolean badgeAuditReset(String gridId); -} \ No newline at end of file + /** + * desc:根据网格id 修改审核状态 + * @param customerId + * @param gridId + * @return + */ + Integer deleteBadgeCertificateAuditing(String customerId, String gridId); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java index 154c8685db..64e38706b6 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java @@ -92,4 +92,12 @@ public interface UserBadgeCertificateRecordService extends BaseService imp } return false; } -} \ No newline at end of file + + @Override + public Integer deleteBadgeCertificateAuditing(String customerId, String gridId) { + return userBadgeCertificateRecordService.deleteBadgeCertificateAuditing(customerId,gridId); + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java index 6f798abc79..a472ebcdae 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.impl; +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; @@ -97,4 +98,13 @@ public class UserBadgeCertificateRecordServiceImpl extends BaseServiceImpl tWrapper = new LambdaQueryWrapper<>(); + tWrapper.eq(UserBadgeCertificateRecordEntity::getCustomerId,customerId) + .eq(UserBadgeCertificateRecordEntity::getGridId,gridId) + .eq(UserBadgeCertificateRecordEntity::getAuditStatus,"auditing"); + return baseDao.delete(tWrapper); + } + +}