diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java index 267de1b18d..8043413311 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java @@ -2,9 +2,11 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.ActInfoDTO; import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.feign.fallback.EpmetHeartOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -28,4 +30,15 @@ public interface EpmetHeartOpenFeignClient { **/ @PostMapping("/heart/resi/volunteer/volunteeruserids") Result> volunteerUserIds(@RequestBody CommonCustomerFormDTO customerFormDTO); + + /** + * 查询用户创建的未结束的活动 + * + * @author zhaoqifeng + * @date 2020/8/28 14:38 + * @param staffId + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("/heart/resi/act/published/{staffId}") + Result> getPublishedAct(@PathVariable String staffId); } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java index 7208b30d92..8c4f0be34a 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java @@ -3,6 +3,7 @@ package com.epmet.feign.fallback; 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.ActInfoDTO; import com.epmet.dto.form.CommonCustomerFormDTO; import com.epmet.feign.EpmetHeartOpenFeignClient; import org.springframework.stereotype.Component; @@ -29,4 +30,9 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli public Result> volunteerUserIds(CommonCustomerFormDTO customerFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "volunteerUserIds", customerFormDTO); } + + @Override + public Result> getPublishedAct(String staffId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "getPublishedAct", staffId); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java index e0f41b198d..73fe6adeb8 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java @@ -3,6 +3,7 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.ActInfoDTO; import com.epmet.dto.form.resi.*; import com.epmet.dto.result.resi.*; import com.epmet.service.*; @@ -331,4 +332,16 @@ public class ResiActListController { ValidatorUtils.validateEntity(formDTO, ResiActContentFormDTO.AddUserInternalGroup.class); return actInfoService.checkSignInTime(formDTO); } + + /** + * 查询用户创建的未结束的活动 + * @author zhaoqifeng + * @date 2020/8/28 14:37 + * @param staffId + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("published/{staffId}") + public Result> getPublishedAct(@PathVariable String staffId) { + return new Result>().ok(actInfoService.getPublishedAct(staffId)); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java index b4fea5476a..2a1522348e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActInfoDao.java @@ -310,4 +310,13 @@ public interface ActInfoDao extends BaseDao { * @Date 11:00 2020-07-20 **/ List selectListLookBackActAssembly(ResiLatestActFormDTO formDTO); + + /** + * 查询用户创建的未结束的活动 + * @author zhaoqifeng + * @date 2020/8/28 14:27 + * @param staffId + * @return java.util.List + */ + List selectPublishedAct(@Param("staffId") String staffId); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java index d1f698480d..dc36ccda4f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActInfoService.java @@ -245,4 +245,13 @@ public interface ActInfoService extends BaseService { * @Date 15:03 2020-08-05 **/ Result checkSignInTime(ResiActContentFormDTO formDTO); + + /** + * 查询用户创建的未结束的活动 + * @author zhaoqifeng + * @date 2020/8/28 14:32 + * @param staffId + * @return java.util.List + */ + List getPublishedAct(String staffId); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java index 0691836f68..9f3649d421 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActInfoServiceImpl.java @@ -416,4 +416,9 @@ public class ActInfoServiceImpl extends BaseServiceImpl().ok(resultDTO); } + + @Override + public List getPublishedAct(String staffId) { + return baseDao.selectPublishedAct(staffId); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml index 20bc885ec1..4ce15b04c7 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml @@ -758,4 +758,12 @@ ORDER BY a.CREATED_TIME DESC LIMIT 0, #{num} + diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index d7a0b5fc61..a9856a4056 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -89,6 +89,12 @@ 2.0.0 compile + + com.epmet + epmet-heart-client + 2.0.0 + compile + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java index 2debda4fce..12d2b81c7e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerDepartmentDao.java @@ -84,4 +84,13 @@ public interface CustomerDepartmentDao extends BaseDao * @Description 查询机关下部门列表信息 **/ List selectAgencyDeptMsgList(@Param("agencyId") String agencyId); + + /** + * 删除工作人员与部门关联 + * @author zhaoqifeng + * @date 2020/8/28 15:12 + * @param staffId + * @return void + */ + void deleteStaffDep(@Param("staffId") String staffId); } \ No newline at end of file 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 1d50d1453a..ec450bfa63 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 @@ -224,4 +224,22 @@ public interface CustomerGridDao extends BaseDao { * @date 2020/8/12 5:10 下午 */ Integer selectGridCount(@Param("customerId")String customerId); + + /** + * 删除工作人员与网格关联 + * @author zhaoqifeng + * @date 2020/8/28 15:32 + * @param staffId + * @return void + */ + void deleteGridStaff(@Param("staffId") String staffId); + + /** + * 查询工作人员所在网格 + * @author zhaoqifeng + * @date 2020/8/28 15:41 + * @param staffId + * @return java.util.List + */ + List selectGridByStaff(@Param("staffId") String staffId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerDepartmentService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerDepartmentService.java index 9722ca82af..bcb0267e38 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerDepartmentService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerDepartmentService.java @@ -92,4 +92,14 @@ public interface CustomerDepartmentService extends BaseService { * @date 2020/8/14 9:31 上午 */ CustomerGridCountResultDTO selectGridCount( CustomerIdFormDTO customerIdFormDTO); + + /** + * 更新网格工作人员关系 + * @author zhaoqifeng + * @date 2020/8/28 15:36 + * @param staffId + * @return void + */ + void updateGrid(String staffId); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerDepartmentServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerDepartmentServiceImpl.java index e3b81d7432..a236f77464 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerDepartmentServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerDepartmentServiceImpl.java @@ -20,11 +20,13 @@ package com.epmet.service.impl; 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.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.CustomerDepartmentDao; import com.epmet.dto.CustomerDepartmentDTO; +import com.epmet.dto.result.DepartmentListResultDTO; import com.epmet.entity.CustomerDepartmentEntity; import com.epmet.redis.CustomerDepartmentRedis; import com.epmet.service.CustomerDepartmentService; @@ -33,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -101,4 +104,25 @@ public class CustomerDepartmentServiceImpl extends BaseServiceImpl list = baseDao.listDepartmentListByStaffId(staffId); + if (null != list && list.size() > NumConstant.ZERO) { + List entityList = new ArrayList<>(); + for (DepartmentListResultDTO dto : list) { + CustomerDepartmentEntity entity = new CustomerDepartmentEntity(); + entity.setId(dto.getDepartmentId()); + entity.setTotalUser(dto.getTotalUser() - NumConstant.ONE); + entityList.add(entity); + } + //更新部门总人数 + updateBatchById(entityList); + //删除工作人员与部门关联 + baseDao.deleteStaffDep(staffId); + } + } + + } \ No newline at end of file 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 afece523c4..215e32b471 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 @@ -649,4 +649,17 @@ public class CustomerGridServiceImpl extends BaseServiceImpl gridList = baseDao.selectGridByStaff(staffId); + if(null != gridList && gridList.size() > NumConstant.ZERO) { + gridList.forEach(entity -> { + entity.setTotalUser(entity.getTotalUser() - 1); + }); + updateBatchById(gridList); + baseDao.deleteGridStaff(staffId); + } + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index 53cf6d9b14..cae5e05475 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -5,19 +5,16 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerAgencyDTO; -import com.epmet.dto.CustomerStaffAgencyDTO; -import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerStaffAgencyEntity; +import com.epmet.feign.EpmetHeartOpenFeignClient; import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.GovProjectOpenFeignClient; import com.epmet.feign.OperCrmFeignClient; -import com.epmet.service.CustomerAgencyService; -import com.epmet.service.CustomerStaffAgencyService; -import com.epmet.service.StaffService; +import com.epmet.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -43,6 +40,14 @@ public class StaffServiceImpl implements StaffService { private CustomerStaffAgencyService customerStaffAgencyService; @Autowired private GovProjectOpenFeignClient govProjectOpenFeignClient; + @Autowired + private EpmetHeartOpenFeignClient epmetHeartOpenFeignClient; + @Autowired + private CustomerDepartmentService customerDepartmentService; + @Autowired + private CustomerGridService customerGridService; + @Autowired + private StaffTransferRecordService staffTransferRecordService; @Override public Result getStaffInfoForHome(StaffsInAgencyFromDTO fromDTO) { @@ -188,6 +193,7 @@ public class StaffServiceImpl implements StaffService { } @Override + @Transactional(rollbackFor = Exception.class) public void staffTransfer(TokenDto tokenDto, StaffTransferFormDTO fromDTO) { //1.获取工作人员与机关关系 CustomerStaffAgencyDTO staffAgencyDTO = customerStaffAgencyService.getInfoByUserId(fromDTO.getStaffId()); @@ -206,11 +212,37 @@ public class StaffServiceImpl implements StaffService { throw new RenException(EpmetErrorCode.EXIT_PEND_PROJECT.getCode()); } //3.查询是否有活动未结束 - + Result> actInfoResult = epmetHeartOpenFeignClient.getPublishedAct(fromDTO.getStaffId()); + if (!actInfoResult.success()) { + throw new RenException(actInfoResult.getCode(), actInfoResult.getMsg()); + } + if (null != actInfoResult.getData() && actInfoResult.getData().size() > NumConstant.ZERO) { + throw new RenException(EpmetErrorCode.EXIT_PUBLISHED_ACTIVITY.getCode()); + } //4.修改人员所属组织 - - //5.逻辑删除工作人员原组织加入的部门、网格,组织人员总数旧的减1新的加1,部门、网格总人数减1 - + CustomerStaffAgencyDTO staffAgency = new CustomerStaffAgencyDTO(); + staffAgency.setId(staffAgencyDTO.getId()); + staffAgency.setAgencyId(fromDTO.getAgencyId()); + customerStaffAgencyService.update(staffAgency); + //原来组织总人数减一 + CustomerAgencyDTO oldAgencyDTO = customerAgencyService.get(oldAgency); + oldAgencyDTO.setTotalUser(oldAgencyDTO.getTotalUser() - NumConstant.ONE); + customerAgencyService.update(oldAgencyDTO); + //新组织总人数加一 + CustomerAgencyDTO newAgencyDTO = customerAgencyService.get(fromDTO.getAgencyId()); + newAgencyDTO.setTotalUser(newAgencyDTO.getTotalUser() - NumConstant.ONE); + customerAgencyService.update(newAgencyDTO); + //5.逻辑删除工作人员原组织加入的部门、网格,部门、网格总人数减1 + customerDepartmentService.updateDepartment(fromDTO.getStaffId()); + customerGridService.updateGrid(fromDTO.getStaffId()); //6.操作记录表新增调动记录 + StaffTransferRecordDTO staffTransferRecordDTO = new StaffTransferRecordDTO(); + staffTransferRecordDTO.setCustomerId(tokenDto.getCustomerId()); + staffTransferRecordDTO.setOperateStaffId(tokenDto.getUserId()); + staffTransferRecordDTO.setOperatedStaffId(fromDTO.getStaffId()); + staffTransferRecordDTO.setOldAgencyId(oldAgency); + staffTransferRecordDTO.setAgencyId(fromDTO.getAgencyId()); + staffTransferRecordDTO.setRemarks(fromDTO.getRemarks()); + staffTransferRecordService.save(staffTransferRecordDTO); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml index a31747facc..bf175e9127 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerDepartmentDao.xml @@ -2,6 +2,10 @@ + + UPDATE customer_staff_department SET DEL_FLAG = '1' + WHERE USER_ID = #{staffId} AND DEL_FLAG = '0' + 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 b9a98117e1..422984c415 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 @@ -2,6 +2,10 @@ + + UPDATE customer_staff_grid SET DEL_FLAG = '1' + WHERE USER_ID = #{staffId} AND DEL_FLAG = '0' + + \ No newline at end of file